Boost logo

Boost :

Subject: [boost] [assign] Boost.Assign is incompatible with std::initializer_list
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2013-12-05 20:11:50


Hi Boost devs,

Our testing has discovered an apparent incompatibility between Boost.Assign and std::initializer_list. I'm using Boost 1.55.0 and a build somewhat newer than VC 2013 RTM (I could check with RTM if someone really wanted me to):

C:\Temp>type meow.cpp
#include <set>
#include <boost/assign/list_of.hpp>

int main() {
    std::set<int> s;

    s = boost::assign::list_of(11)(22)(33);
}

C:\Temp>cl /EHsc /nologo /W4 /MTd meow.cpp /I boost_1_55_0
meow.cpp
meow.cpp(7) : error C2593: 'operator =' is ambiguous
        E:\binaries\x86ret\inc\set(180): could be 'std::set<int,std::less<_Kty>,std::allocator<_Kty>> &std::set<_Kty,std::less<_Kty>,std::allocator<_Kty>>::operator =(std::initializer_list<int>)'
        with
        [
            _Kty=int
        ]
        E:\binaries\x86ret\inc\set(139): or 'std::set<int,std::less<_Kty>,std::allocator<_Kty>> &std::set<_Kty,std::less<_Kty>,std::allocator<_Kty>>::operator =(std::set<_Kty,std::less<_Kty>,std::allocator<_Kty>> &&)'
        with
        [
            _Kty=int
        ]
        E:\binaries\x86ret\inc\set(123): or 'std::set<int,std::less<_Kty>,std::allocator<_Kty>> &std::set<_Kty,std::less<_Kty>,std::allocator<_Kty>>::operator =(const std::set<_Kty,std::less<_Kty>,std::allocator<_Kty>> &)'
        with
        [
            _Kty=int
        ]
        while trying to match the argument list '(std::set<int,std::less<_Kty>,std::allocator<_Kty>>, boost::assign_detail::generic_list<int>)'
        with
        [
            _Kty=int
        ]

Note that this repros with std::set and not with std::vector because of a bizarre compiler bug (it's sensitive to the order in which operator=() overloads are declared, and std::set's order is different from std::vector's).

Although we've got that compiler bug (and another one affecting overload resolution for braced-init-lists which shouldn't be relevant here), I believe this compiler error is correct, and Boost.Assign is buggy.

http://www.boost.org/doc/libs/1_55_0/libs/assign/doc/index.html#list_of_ref depicts an unconstrained "operator Container()", which worked until the containers gained op=() for initializer_list.

Is this a known issue? (It should repro for other platforms, although I haven't checked.) Should this conversion operator be constrained so it can't be instantiated for initializer_list?

Thanks,
STL


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk