Questions tagged [libc++]

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

469 questions
262
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
127
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
  • 6,064
  • 5
  • 31
  • 43
116
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++?
MobileDev
  • 3,750
  • 4
  • 32
  • 35
92
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
  • 206,506
  • 52
  • 449
  • 577
74
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
  • 841
  • 1
  • 7
  • 5
71
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
  • 7,287
  • 9
  • 51
  • 78
65
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
  • 7,287
  • 9
  • 51
  • 78
57
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
  • 589
  • 1
  • 4
  • 6
47
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,857
  • 7
  • 29
  • 29
43
votes
1 answer

Why is initializing a string to "" more efficient than the default constructor?

Generally, the default constructor should be the fastest way of making an empty container. That's why I was surprised to see that it's worse than initializing to an empty string literal: #include std::string make_default() { return…
Jan Schultke
  • 17,446
  • 6
  • 47
  • 96
39
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
  • 9,451
  • 13
  • 58
  • 102
32
votes
6 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,659
  • 1
  • 13
  • 22
31
votes
1 answer

The reasoning behind Clang's implementation of std::function's move semantics

In libc++'s implementation of std::function, if the function object whose type is being erased is small enough to fit inside an SBO then the move operation will copy it, not move it. Yet not every object whose stack memory footprint is small is…
GreenScape
  • 7,191
  • 2
  • 34
  • 64
30
votes
4 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,215
  • 2
  • 11
  • 22
30
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
31 32