On 31/12/2016 17:44, Daniel Trstenjak wrote:
Hi,
first the used versions: boost 1.63.0 gcc 5.4.0 20160609 Ubuntu 16.04.1
the example I've problems with is:
#include <map> #include
using boost::container::small_vector;
typedef std::pair
> mypair; typedef std::map
mymap; typedef std::map > mymap2; typedef std::map , 8> > mymap3; int main() { mymap m; mypair& sv = m[0];
mymap2 m2; small_vector
& sv2 = m2[0]; mymap3 m3; small_vector
, 8>& sv3 = m3[0]; }
In C++98 std::pair copy constructor is implicitly declared. Since small_vector declares operator= taking a non-const reference (as that's how move semantics are emulated), then std::pair's operator= takes a non-const pair argument: http://en.cppreference.com/w/cpp/language/copy_assignment#Implicitly-declare... So the problem you are facing it's a limitation of the move emulation library. When you define your own class holding a small_vector, you have the same problem. When you explicitly declare operator= taking a const reference the problem is solved. See: http://www.boost.org/doc/libs/1_63_0/doc/html/move/emulation_limitations.htm... and http://www.boost.org/doc/libs/1_63_0/doc/html/container/known_issues.html#co... Best, Ion