Boost logo

Boost :

Subject: [boost] [unordered] unordered_map forces non-const version of automatic assignment operator
From: STEAG Energy Services GmbH (Tobias.Loew_at_[hidden])
Date: 2011-11-23 11:39:38


I just switched from boost version 1.47 to 1.48 and now I've got the effect that my compiler (msvc 2008) generates the wrong (i.e. non-const) assignment operator in the following example:

struct copy_test
//#define USER_ASSIGN
    copy_test & operator = (const copy_test & other)
        map =;
        return *this;
    boost::unordered_map<std::wstring,std::wstring> map;

void foo()
    copy_test a,b;
    const copy_test c;
    a=c; // error if USER_ASSIGN is not defined


I think the reason is use of BOOST_COPY_ASSIGN_REF in unordered_map.hpp:148, as it expands the assignment operator to

unordered_map& operator=(const ::boost::rv<unordered_map>& x)

I think the same problems arise on other compilers without rv-references and containers that use BOOST_COPY_ASSIGN_REF.



Boost list run by bdawes at, gregod at, cpdaniel at, john at