fork(3) download
  1. #include <string>
  2.  
  3. #include <iostream>
  4.  
  5. template<size_t symbols_count> auto
  6. foo(const char (& sz_text)[symbols_count]) -> void { ::std::cout << 0; }
  7.  
  8. template<typename tp_Char> auto
  9. foo(tp_Char const * & psz_text) -> void { ::std::cout << 1; }
  10.  
  11. template<typename tp_Char> auto
  12. foo(tp_Char const * && psz_text) -> void { ::std::cout << 2; }
  13.  
  14. int main()
  15. {
  16. foo("qqq"); // вызовет (0)
  17.  
  18. const char sz_text[] = {"www"};
  19.  
  20. foo(sz_text); // вызовет (0)
  21.  
  22. char const * psz_text("eee");
  23.  
  24. foo(psz_text); // вызовет (1)
  25.  
  26. ::std::string text("rrr");
  27.  
  28. foo(text.c_str()); // // вызовет (2)
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
0012