When
- a constructor is called with an initializer list, made up of {}-initializers for a user-defined type
icpc complains with
error: no instance of constructor matches the argument list
while gcc (4.8.1) happily compiles the code.
How to reproduce:
#include <string>
#include <vector>
class Element {
public:
Element(std::string const & s) :
data(s)
{ }Element(std::string && s) :
data(s)
{ }std::string const & read() const {
return data;
}private:
std::string data;
};int main(void) {
std::vector<Element> elements { { "hello" }, { "world" } };
}
Here is the actual error:
$ icpc -std=c++11 test.cpp -o test
test.cc(24): error: no instance of constructor "std::vector<_Tp, _Alloc>::vector [with _Tp=Element, _Alloc=std::allocator<Element>]" matches the argument list
argument types are: ({...}, {...})
std::vector<Element> elements { { "hello" }, { "world" } };
^
compilation aborted for test.cc (code 2)