fork download
  1. #include <memory>
  2.  
  3. template<typename T, typename ...Args>
  4. std::unique_ptr<T> make_unique(Args&& ...args) {
  5. return std::unique_ptr<T>(new T{std::forward<Args>(args)...});
  6. }
  7.  
  8. struct S {
  9. template<class... Args>
  10. static std::unique_ptr<S> create(Args&&... args) {
  11. return std::unique_ptr<S>(new S(std::forward<Args>(args)...));
  12. }
  13. private: // if I remove this line, then the compilation is OK
  14. S(int) {}
  15. S() = default;
  16. };
  17.  
  18. int main() {
  19. auto s1 = S::create(); // OK
  20. auto s2 = S::create(0); // Now OK as well
  21. }
Success #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty