c++ - Transfer specified number of bytes from one stringstream to another -


given

  • a size_t n (typically valued in millions)
  • a stringstream a, containing many more n bytes
  • a pre-existing empty stringstream b

what might way transfer n bytes a b?

i think following work

std::string s; s.resize(n); a.read(&s[0], n); b << s.rdbuf(); 

but isn't there way skip intermediate string s , transfer n bytes directly a b?


Comments

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -