This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Should this work?


#include <string>
#include <iostream>
#include <sstream>

int main()
{
	std::ostringstream os;
	os << "Hello there, c++ dudes";
	
	std::cout << os.str().end() - os.str().begin() << std::endl;
}

It looks like os.str().end() and os.str().begin() are iterators over
different sequences, so you get some strange results. It's easy to fix
by using a temporary

string temp = os.str();

but I was wondering if it exhibits the correct behaviour without the
temporary?

bye
John

-- 

Freelance DataDreamer http://www.semiosix.com
Good Things require a precise lack of control


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]