fork download
  1. #include <memory>
  2. #include <type_traits>
  3.  
  4. struct wrapper {
  5. template<
  6. typename T
  7. , typename... Ts
  8. , typename = typename std::enable_if<
  9. !std::is_same<wrapper, typename std::decay<T>::type>::value
  10. >::type
  11. >
  12. wrapper(T&& t, Ts&&... ts)
  13. : p(std::forward<T>(t), std::forward<Ts>(ts)...)
  14. {}
  15.  
  16. std::unique_ptr<int> p;
  17. };
  18.  
  19. int
  20. main()
  21. {
  22. // fine
  23. wrapper w = nullptr;
  24.  
  25. // not fine:
  26. // error: use of deleted function 'wrapper::wrapper(const wrapper&)'
  27. wrapper const cw = nullptr;
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:23:17: error: 'nullptr' was not declared in this scope
stdout
Standard output is empty