fork download
  1. #include<iostream>
  2. #include<vector>
  3. #include<functional>
  4. #include<string>
  5.  
  6.  
  7. template<typename Type,
  8. typename Return,
  9. typename Container,
  10. typename Parameter>
  11. Container
  12. StringTo (Type&& copy,
  13. const char tokens[],
  14. Return (Container::*Insert) (const Parameter&))
  15. {
  16. static_assert(not std::is_lvalue_reference<Type>::value, "Must be rvalue.");
  17. Container container;
  18. return container;
  19. }
  20.  
  21. template<typename Type>
  22. auto
  23. StringToVector (Type&& copy,
  24. const char tokens[])
  25. {
  26. static_assert(not std::is_lvalue_reference<Type>::value, "Must be rvalue.");
  27. return StringTo(std::move(copy), tokens, &std::vector<Type>::push_back);
  28. }
  29.  
  30.  
  31. int main()
  32. {
  33. auto v = StringToVector(std::string("hello world"), " ");
  34. }
Success #stdin #stdout 0s 4488KB
stdin
Standard input is empty
stdout
Standard output is empty