title: c++ -std=c++11 -stdlib=libc++ giving errors on osx lion
body: <p>This ought to be a duplicate question. But I've googled quite a bit and haven't found a hit that fixes my issue.</p>
  
  <p>I'm trying to use a c++11 standard feature on osx lion and it's not working. I believe this feature is called list initializers. according to <a href="http://clang.llvm.org/cxx_status.html" rel="nofollow">http://clang.llvm.org/cxx_status.html</a> This feature was in clang 3.1, which is the version I'm using.</p>
  
  <p>Below is the shell o/p explaining my simple test. Can anyone tell me what I'm doing wrong? Am I forgetting a flag?</p>
  
  <p>The compiler is:</p>
  
  <pre><code>:tmp$ c++ --version
  Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
  Target: x86_64-apple-darwin11.4.2
  Thread model: posix
  :tmp$ which c++
  /usr/bin/c++
  :tmp$ ls -alt /usr/bin/c++
  lrwxr-xr-x  1 root  wheel  7 Jul 12 13:17 /usr/bin/c++ -&gt; clang++
  </code></pre>
  
  <p>The OS is</p>
  
  <pre><code>:tmp$ uname -a
  Darwin .local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
  </code></pre>
  
  <p>The test file is</p>
  
  <pre><code>:tmp$ cat test.cpp
  #include &lt;vector&gt;
  
  int main(){
    std::vector&lt;int&gt; vec1 {1,2,3};
    std::vector&lt;int&gt; vec2={1,2,3};
  }
  </code></pre>
  
  <p>The compiler output is</p>
  
  <pre><code>:tmp$ c++ -std=c++11 test.cpp
   test.cpp:4:20: error: non-aggregate type 'std::vector&lt;int&gt;' cannot be
        initialized with an initializer list
    std::vector&lt;int&gt; vec1 {1,2,3};
                     ^    ~~~~~~~
  test.cpp:5:20: error: non-aggregate type 'std::vector&lt;int&gt;' cannot be
        initialized with an initializer list
    std::vector&lt;int&gt; vec2={1,2,3};
                     ^    ~~~~~~~
  2 errors generated.
  </code></pre>
  
  <p>Ok I didn't want to get there because the following takes a lot to format properly on stackoverflow. But adding -stdlib=c++ creates even more problems. Now I get 14 errors.</p>
  
  <pre><code>:tmp$ c++ -std=c++11 -stdlib=libc++ test.cpp 
  In file included from test.cpp:1:
  In file included from /usr/bin/../lib/c++/v1/vector:261:
  In file included from /usr/bin/../lib/c++/v1/__bit_reference:15:
  In file included from /usr/bin/../lib/c++/v1/algorithm:591:
  /usr/bin/../lib/c++/v1/type_traits:737:2: error: #error is_base_of not
        implemented.
  #error is_base_of not implemented.
   ^
  /usr/bin/../lib/c++/v1/type_traits:1700:13: error: use of undeclared identifier
        'is_base_of'
              is_base_of&lt;_Class, typename remove_reference&lt;_Tp&gt;::type&gt;::value&gt;
              ^
  /usr/bin/../lib/c++/v1/type_traits:1700:24: error: '_Class' does not refer to a
        value
              is_base_of&lt;_Class, typename remove_reference&lt;_Tp&gt;::type&gt;::value&gt;
                     ^
  /usr/bin/../lib/c++/v1/type_traits:1697:28: note: declared here
  template &lt;class _Rp, class _Class, class _Tp&gt;
                             ^
  /usr/bin/../lib/c++/v1/type_traits:1700:62: error: expected class name
              is_base_of&lt;_Class, typename remove_reference&lt;_Tp&gt;::type&gt;::value&gt;
                                                               ^
  In file included from test.cpp:1:
  In file included from /usr/bin/../lib/c++/v1/vector:261:
  In file included from /usr/bin/../lib/c++/v1/__bit_reference:15:
  In file included from /usr/bin/../lib/c++/v1/algorithm:594:
  In file included from /usr/bin/../lib/c++/v1/memory:590:
  In file included from /usr/bin/../lib/c++/v1/typeinfo:61:
  /usr/bin/../lib/c++/v1/exception:194:20: error: use of undeclared identifier
        'is_base_of'
                    !is_base_of&lt;nested_exception, typename ...
                 ^
  /usr/bin/../lib/c++/v1/exception:194:31: error: 'nested_exception' does not
        refer to a value
                    !is_base_of&lt;nested_exception, typename ...
                                ^
  /usr/bin/../lib/c++/v1/exception:166:29: note: declared here
  class _LIBCPP_EXCEPTION_ABI nested_exception
                              ^
  /usr/bin/../lib/c++/v1/exception:194:81: error: parameter declarator cannot be
        qualified
    ...typename remove_reference&lt;_Tp&gt;::type&gt;::value
                                     ~~^
  /usr/bin/../lib/c++/v1/exception:194:85: error: expected ')'
    ...typename remove_reference&lt;_Tp&gt;::type&gt;::value
                                           ^
  /usr/bin/../lib/c++/v1/exception:192:18: note: to match this '('
  throw_with_nested(_Tp&amp;&amp; __t, typename enable_if&lt;
                   ^
  /usr/bin/../lib/c++/v1/exception:213:19: error: use of undeclared identifier
        'is_base_of'
                    is_base_of&lt;nested_exception, typename ...
                ^
  /usr/bin/../lib/c++/v1/exception:213:30: error: 'nested_exception' does not
        refer to a value
                    is_base_of&lt;nested_exception, typename ...
                           ^
  /usr/bin/../lib/c++/v1/exception:166:29: note: declared here
  class _LIBCPP_EXCEPTION_ABI nested_exception
                              ^
  /usr/bin/../lib/c++/v1/exception:213:80: error: parameter declarator cannot be
        qualified
    ...typename remove_reference&lt;_Tp&gt;::type&gt;::value
                                     ~~^
  /usr/bin/../lib/c++/v1/exception:213:84: error: expected ')'
    ...typename remove_reference&lt;_Tp&gt;::type&gt;::value
                                           ^
  /usr/bin/../lib/c++/v1/exception:211:18: note: to match this '('
  throw_with_nested(_Tp&amp;&amp; __t, typename enable_if&lt;
                   ^
  test.cpp:4:20: error: non-aggregate type 'std::vector&lt;int&gt;' cannot be
        initialized with an initializer list
    std::vector&lt;int&gt; vec1 {1,2,3};
                     ^    ~~~~~~~
  test.cpp:5:20: error: non-aggregate type 'std::vector&lt;int&gt;' cannot be
        initialized with an initializer list
    std::vector&lt;int&gt; vec2={1,2,3};
                     ^    ~~~~~~~
  14 errors generated.
  </code></pre>