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