fork download
  1. #include <type_traits>
  2.  
  3. using namespace std;
  4.  
  5. template <typename T>
  6. struct A
  7. {
  8. typedef typename add_const<T>::type TT;
  9. };
  10.  
  11. template <typename T>
  12. struct B
  13. {
  14. typedef const T TT;
  15. };
  16.  
  17. static_assert(is_same<const int, A<int>::TT>::value, "A<int> wrong");
  18. static_assert(is_same<const int, A<const int>::TT>::value, "A<const int> wrong");
  19. static_assert(is_same<int&, A<int&>::TT>::value, "A<int&> wrong");
  20. static_assert(is_same<const int, B<int>::TT>::value, "B<int> wrong");
  21. static_assert(is_same<const int, B<const int>::TT>::value, "B<const int> wrong");
  22. static_assert(is_same<int&, B<int&>::TT>::value, "B<int&> wrong");
  23.  
  24. int main() {}
  25.  
Success #stdin #stdout 0s 2848KB
stdin
Standard input is empty
stdout
Standard output is empty