
7 Dec
2006
7 Dec
'06
3:50 p.m.
Hi all, I was trying to understand the use of boost::ref and boost::cref and wrote this little snippet: #include <iostream> #include <boost/ref.hpp> #include <string> using namespace std; int main(int argc,char** argv) { boost::reference_wrapper<string const> ref=boost::cref(string("yoh")); const string das("bla"); const string & dasref=das; cout<<"das ref is "<<dasref<<endl; cout<<"ref is "<<ref.get()<<endl; return 0; } I am confused by what I get when I run this: das ref is bla ref is bla I was expecting: das ref is bla ref is yoh What am I doing wrong there ??