Std :: ostringstream woes

I can do

std::ostringstream oss; oss << 1; oss.str(); 

so why can't I:

 ((std::ostringstream()) << 1).str() ? 

Thanks!

+4
source share
1 answer

The operator << returns the base type ostream , and the member function str exists only on the derived type ostringstream .

+11
source

Source: https://habr.com/ru/post/1300243/


All Articles