Guest User

Untitled

a guest
Jul 19th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. struct copy_only {
  2. copy_only(copy_only const&) {} // note: not defaulted on first declaration
  3. };
  4. static_assert( std::is_move_constructible<copy_only>::value
  5. , "This won't trip" );
  6.  
  7. #include <type_traits>
  8.  
  9. template <typename T, bool P> struct is_movecopy_helper;
  10.  
  11. template <typename T>
  12. struct is_movecopy_helper<T, false>
  13. {
  14. typedef T type;
  15. };
  16.  
  17. template <typename T>
  18. struct is_movecopy_helper<T, true>
  19. {
  20. template <typename U>
  21. struct Dummy : public U
  22. {
  23. Dummy(const Dummy&) = delete;
  24. Dummy(Dummy&&) = default;
  25. };
  26. typedef Dummy<T> type;
  27. };
  28.  
  29. template <class T>
  30. struct has_move_constructor
  31. : std::integral_constant<bool, std::is_class<T>::value &&
  32. std::is_move_constructible<typename is_movecopy_helper<T, std::is_class<T>::value>::type>::value> { };
Add Comment
Please, Sign In to add comment