Is the std::map default constructor explicit?

Viewed 675

The following code compiles fine on g++ (various versions) but fails on clang++-3.4 with libc++ on my system:

#include <map>
#include <string>

std::map<std::string, std::string> f() {
    return {};
}

int main() {
    auto m = f();
}

clang marks the following problem:

x.cpp:6:12: error: chosen constructor is explicit in copy-initialization
    return {};
           ^~
/usr/local/Cellar/llvm34/3.4.2/lib/llvm-3.4/bin/../include/c++/v1/map:838:14: note: constructor declared here
    explicit map(const key_compare& __comp = key_compare())
             ^

Indeed, the include file declares the constructor as explicit. But it’s not marked as such in my C++11 draft standard. Is this a bug in clang++/libc++? I was unable to find a relevant bug report.

1 Answers
Related