fork download
  1. #include <utility>
  2.  
  3. template<typename T>
  4. union _impl_itca_helper { T dummy; };
  5.  
  6. template<typename T>
  7. std::true_type _impl_itca (T, int,
  8. decltype (
  9. (std::declval<_impl_itca_helper<T>> () = std::declval<_impl_itca_helper<T>> ()),
  10. int { }
  11. ) = 0
  12. );
  13.  
  14. template<typename T, typename U>
  15. std::false_type _impl_itca (T, U);
  16.  
  17. template<typename T>
  18. using is_trivially_copy_assignable = decltype (
  19. _impl_itca (std::declval<T> (), int { })
  20. );
  21.  
  22. int
  23. main (int argc, char *argv[])
  24. {
  25. struct Obj1 { Obj1& operator= (Obj1 const&) = default; };
  26. struct Obj2 { Obj1& operator= (Obj2 const&); };
  27.  
  28. static_assert (
  29. is_trivially_copy_assignable<Obj1>::value,
  30. "Obj1 is not trivially copy assignable"
  31. );
  32.  
  33. static_assert (
  34. is_trivially_copy_assignable<Obj2>::value,
  35. "Obj2 is not trivially copy assignable"
  36. );
  37. }
  38.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:33:3: error: static assertion failed: Obj2 is not trivially copy assignable
   static_assert (
   ^
stdout
Standard output is empty