Boost logo

Boost :

Subject: Re: [boost] [unordered] Visual C++ 2013 initializer_listoverloadfailure.
From: Daniel James (daniel_at_[hidden])
Date: 2013-11-05 07:09:48

On 5 November 2013 11:45, Joaquin M Lopez Munoz <joaquin_at_[hidden]> wrote:
> Inspecting the log seems like you tried something and then reverted
> the commit. Didn't it work or did you just prefer to leave the
> VC bug exposed in wait for it to be fixed by MS themselves?

It didn't work. I don't have access to the compiler so I was just
guessing. I also had made a mistake configuring boost build, so when I
thought I was testing with gcc 4.8 in C++11 mode, I wasn't. So I made
a bit of a mess and felt it was better left until later. There were
already enough problems with the compiler.

My basic idea is to do something like the following and hope that it's
possible to make the template overload match where appropriate. Might
also need to use enable_if to prevent some incorrect matches. But even
if I could get it to work, it could be very fragile. Presumably this
bug will also affect the standard containers as well, so maybe it's
not something worth fixing. At least it's a compile error, and not
silently picking the wrong overload.

#include <initializer_list>
#include <string>
#include <iostream>

template <typename T>
struct container
    void insert(T const& x)
        std::cout << "1" << std::endl;

    void insert(std::initializer_list<T> x) {
        std::cout << "2" << std::endl;

    template <typename T1>
    void insert(std::initializer_list<T1> x) {
        std::cout << "3" << std::endl;

int main()
    container<std::string> c;

    std::cout << "String literal:\n";

    std::cout << "std::string:\n";

    std::cout << "initializer list of std::string:\n";
    c.insert({std::string("a"), std::string("b")});

    std::cout << "initializer list of string literals:\n";
    c.insert({"a", "b"});
    c.insert({"a", "b", "c"});

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