fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. using namespace std;
  5.  
  6. template <class T>
  7. void print_stats( T&& )
  8. {
  9. std::cout << "-------------------------" << std::endl;
  10. std::cout << "is_array=" << std::is_array<T>::value << std::endl;
  11. std::cout << "is_const=" << std::is_const<T>::value << std::endl;
  12. std::cout << "is_lvalue_reference=" << std::is_lvalue_reference<T>::value << std::endl;
  13. std::cout << "is_rvalue_reference=" << std::is_rvalue_reference<T>::value << std::endl;
  14. }
  15.  
  16. int main() {
  17. // your code goes here
  18. std::string x;
  19. print_stats(x);
  20.  
  21. print_stats( std::string{} );
  22.  
  23. std::string y;
  24. print_stats(std::move(y));
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
-------------------------
is_array=0
is_const=0
is_lvalue_reference=1
is_rvalue_reference=0
-------------------------
is_array=0
is_const=0
is_lvalue_reference=0
is_rvalue_reference=0
-------------------------
is_array=0
is_const=0
is_lvalue_reference=0
is_rvalue_reference=0