0

I'm trying to compile C++11 list congregation initialization on clang++ on mac.

#include <iostream>
#include <list>
#include <string>

using namespace std;
int main(int argc, char *argv[]) {
    list<string> aList = {"abc", "def", "xyz"};
}

This is the command for the compilation.

clang++-mp-3.1 -std=c++11 iterator.cpp

I got no matching constructor error.

iterator.cpp:7:23: error: no matching constructor for initialization of
  'std::list<string>'
std::list<string> aList = {"abc", "def", "xyz"};
                  ^       ~~~~~~~~~~~~~~~~~~~~~

I tried with XCode

clang -v
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

I also tried with clang++ from port

clang++-mp-3.1 -v
clang version 3.1 (branches/release_31)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

I got the same result. What might be wrong?

clang's support of C++ 11 lambda

Community
  • 1
  • 1
prosseek
  • 182,215
  • 215
  • 566
  • 871

1 Answers1

0

I tried icc, got the same error. I guess the issue is with the template not the compiler. icc uses existing template /usr/include/c++/4.2.1 and the implementation doesn't support c++11 fully.

I tried gcc 4.8 from port

sudo port install gcc48

It works fine

/opt/local/bin/g++-mp-4.8 -std=c++11 Iterator.cpp 

How to turn on C++0x of Intel C++ Compiler 12.1.2

Community
  • 1
  • 1
prosseek
  • 182,215
  • 215
  • 566
  • 871