fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. struct S {
  5. template<typename T>
  6. S(const T& t)
  7. { std::cout << "T t\n"; }
  8.  
  9. std::string value_;
  10. };
  11.  
  12.  
  13. template<>
  14. S::S(const std::string&) {
  15. std::cout << "const string&\n";
  16. }
  17.  
  18. int main() {
  19. S s1(42);
  20.  
  21. std::string foo{"bar"};
  22. const std::string& foor = foo;
  23. S s2(foo);
  24. S s3(foor);
  25. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
T t
const string&
const string&