fork download
  1. #include <sstream>
  2. #include <string>
  3.  
  4. class MyClass : public std::istringstream{
  5. public:
  6. using std::istringstream::operator >>;
  7. MyClass(const char* st) : std::istringstream(st){}
  8. void operator>>(std::string& st){st = this->str();}
  9. };
  10.  
  11. int main()
  12. {
  13. MyClass my("bla tmp");
  14. std::string tmp;
  15. my >> tmp; // now tmp == "bla temp" and this is exactly what I wanted
  16. //but this does not work
  17. int kk;
  18. my >> kk; //gives me "now match for operator>>"
  19. }
  20.  
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout

Standard output is empty