Questions tagged [libc++]

libc++ is an open C++ Standard Library implementation, and a subproject of LLVM.org. It has been designed for C++11.

419 questions
221
votes
6 answers

std::unique_ptr with an incomplete type won't compile

I'm using the pimpl-idiom with std::unique_ptr: class window { window(const rectangle& rect); private: class window_impl; // defined elsewhere std::unique_ptr impl_; // won't compile }; However, I get a compile error regarding…
user1203803
110
votes
2 answers

What are the mechanics of short string optimization in libc++?

This answer gives a nice high-level overview of short string optimization (SSO). However, I would like to know in more detail how it works in practice, specifically in the libc++ implementation: How short does the string have to be in order to…
ValarDohaeris
  • 5,269
  • 5
  • 25
  • 41
96
votes
2 answers

Should I use libc++ or libstdc++?

I am developing command line interface executables for both osx and linux using c/c++. The project will link against opencv. Should I use libc++ or libstdc++?
Loozie
  • 3,470
  • 3
  • 28
  • 34
93
votes
1 answer

Why is libc++'s vector::const_reference not bool?

Section 23.3.7 Class vector [vector.bool], paragraph 1 states: template class vector { public: // types: typedef bool const_reference; ... However this program fails to compile when…
Howard Hinnant
  • 179,402
  • 46
  • 391
  • 527
73
votes
1 answer

Using libstdc++ compiled libraries with clang++ -stdlib=libc++

I am working in C++ under Mac OS X (10.8.2) and I recently came up with the need of using C++11 features, which are available through the clang++ compiler using the libc++ stdlib. However, I also need to use some legacy library compiled and linked…
user1690715
  • 831
  • 1
  • 7
  • 5
67
votes
2 answers

How to compile/link Boost with clang++/libc++?

The answer to this question Why can't clang with libc++ in c++0x mode link this boost::program_options example? states "You need to rebuild boost using clang++ -stdlib=libc++." I'm using MacOS Lion with clang v3.0. How do I build Boost v1.48.0 using…
x-x
  • 6,783
  • 9
  • 46
  • 74
64
votes
1 answer

Why can't clang with libc++ in c++0x mode link this boost::program_options example?

Compiling this example code for boost::program_options: http://svn.boost.org/svn/boost/trunk/libs/program_options/example/first.cpp ...on MacOS Lion (10.7.2), using boost-1.48.0 installed with MacPorts: $ clang++ -v Apple clang version 3.0…
x-x
  • 6,783
  • 9
  • 46
  • 74
54
votes
4 answers

Is make_shared really more efficient than new?

I was experimenting with shared_ptr and make_shared from C++11 and programmed a little toy example to see what is actually happening when calling make_shared. As infrastructure I was using llvm/clang 3.0 along with the llvm std c++ library within…
user1212354
  • 559
  • 1
  • 4
  • 6
43
votes
2 answers

Printing/Debugging libc++ STL with Xcode/LLDB

I'm trying to use LLDB within Xcode 8 to debug very basic STL. I used to be able to print a vector like this: p myvector[0] to see whatever was in the first vector index. Now when I do that, I get this error: error: Couldn't lookup symbols: …
cjserio
  • 2,747
  • 7
  • 26
  • 29
38
votes
1 answer

Does libcxxabi makes sense under linux? What are the benefits?

I'm trying to determine if building and using libcxxabi from the llvm project under linux makes sense. My build of libcxxabi is linked to ldd libc++abi.so.1.0 linux-vdso.so.1 => (0x00007fff2e0db000) libpthread.so.0 =>…
user2485710
  • 8,623
  • 9
  • 48
  • 92
30
votes
3 answers

Compiling with Clang using Libc++ undefined references

The first couple are too long to reference. I get this error when I try to compile clang++ -stdlib=libc++ ../main.cc ... with clang and libc++ from the SVN. error: undefined reference to 'typeinfo for char const*' error: undefined reference to…
norcalli
  • 1,186
  • 2
  • 10
  • 22
28
votes
1 answer

Why does libc++'s implementation of shared_ptr use full memory barriers instead of relaxed?

In boost's implementation of shared_ptr, it uses relaxed memory ordering to increment its reference count. This appears safe as decrements use acquire/release to make sure that any previous decrements are visible to the thread before releasing…
Christopher Tarquini
  • 10,226
  • 15
  • 50
  • 72
28
votes
1 answer

Boost Spirit Qi - Duplicate last letter with stream-based parsing

This may be very obvious, but why does the stream-based parsing in boost duplicate the last letter? I must be doing something wrong: #include #include #include namespace qi =…
kloffy
  • 2,878
  • 1
  • 23
  • 32
26
votes
4 answers

Install libc++ on ubuntu

I am wondering what is the right/easy way to install a binary libc++ on Ubuntu, in my case Trusty aka 14.04? On the LLVM web site there are apt packages http://apt.llvm.org/ and I have used these to install 3.9. However these packages don't seem to…
goneskiing
  • 1,367
  • 1
  • 10
  • 17
24
votes
2 answers

Enable libc++/libcxx by default when using clang++

I installed clang from scratch following the instructions here. Afterwards, I installed libc++ using libsupc++ according to the instructions here. Now, whenever I compile & link a program with clang and libc++, I need to issue a command like…
1
2 3
27 28