id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 3977,Compile error on make_nvp with reference data member,kondo@…,Robert Ramey,"When I save the reference data member to the xml_archive by using make_nvp, the compile error occurs. Attached file 'ref_direct.cpp' is an example program to reproduce problem. {{{ #!cpp // Compile error! ar << boost::serialization::make_nvp(""ref_"", &p->ref_); }}} The error message is below. {{{ error: invalid initialization of non-const reference of type ‘MyInt*&’ from a temporary of type ‘MyInt*' }}} We can avoid this error using additional variable or using static_cast. {{{ #!cpp // OK MyInt* pRef = &p->ref_; ar << boost::serialization::make_nvp(""ref_"", pRef); }}} {{{ #!cpp // OK ar << boost::serialization::make_nvp(""ref_"", static_cast(&p->ref_)); }}} But I think it's not elegant. My idea is that introducing the new overload of make_nvp function template. {{{ #!cpp template inline #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING const #endif nvp make_nvp(const char * name, const T & t){ return nvp(name, t); } }}} It resolves this problem. Please check 'nvp_const_ref.patch' (attached file). After apply the patch, I already did the regression test of serialization. All test is passed. My testing environments are g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1 and VC++ 9.0 on Windows7. ",Patches,closed,Boost 1.43.0,serialization,Boost 1.42.0,Problem,wontfix,,