libc++

C++11 standard libraries in libstdc++ on Mac

点点圈 提交于 2019-12-23 02:02:05
问题 In a Xcode project which I currently work on, I am using C++11 with Apple LLVM 4.2 (clang) compiler, and using libstdc++ as my standard library, because I am using a library (NTL) which was not compiled with libc++ and so I must use libstdc++. When writing the following code: #include <regex> int main() { return 0; } It doesn't compile, by saying: 'regex' file not found And so I can't use any C++11 library with my libstdc++ (Tried <mutex> , <thread> aswell). Another I tried to take is to

How to link to libc++ on /usr/local/lib?

孤街浪徒 提交于 2019-12-22 18:28:32
问题 I've tried to provide -L /usr/local/lib , tried -nostdinc++ , tried to set DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH but otool aways gives me: otool -L sample sample: /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) How to link to my custom compiled /usr/local/lib/libc++.dylib on OS X? Variations of compilation were upon basic clang++ -std=c++11 -stdlib=libc++ . 回答1: As you've

How to use experimental parallel STL in C++1z?

断了今生、忘了曾经 提交于 2019-12-22 08:35:45
问题 I want to try parallel STL of C++17. However, I can't find experimental/execution_policy in libc++. How can I try this? I'm trying http://en.cppreference.com/w/cpp/experimental/reduce, which says I should include these files, but I cannot find execution_policy. #include <experimental/execution_policy> After I install libc++ (I followed http://libcxx.llvm.org/docs/BuildingLibcxx.html), I tried the following commands, but in vain. $ clang++-3.5 -std=c++1z test.cpp -lc++experimental test.cpp:5

clang 3.3/Xcode & libc++: std::getline does not read data after calling ifstream::clear()

≯℡__Kan透↙ 提交于 2019-12-22 07:06:40
问题 The following program demonstrates an inconsistency in std::getline behavior between libc++ and libstdc++ (using clang3.3). The program opens the file testfile, reads it until eof, then clears the error bits using ifstream::clear and tries to read from the same filehandle again to see if new data was appended to the file. #include <fstream> #include <iostream> #include <unistd.h> using namespace std; int main() { ifstream* file = new ifstream("testfile"); if ( ! file->is_open() ) { cout <<

Why does libstdc++ store std::tuple elements in reverse order?

我的未来我决定 提交于 2019-12-22 04:47:09
问题 According to http://flamingdangerzone.com/cxx11/2012/07/06/optimal-tuple-i.html, with regards to std::tuple... libstdc++ always places the members in reverse order, and libc++ always places the members in the order given Assuming that's true, is there a reason (historical or otherwise) why libstdc++ uses reverse order? Bonus: Has either implementation ever changed its std::tuple ordering for any reason? 回答1: See this answer for why libc++ chose forward order. As for why libstdc++ chose

On libc++, why does regex_match(“tournament”, regex(“tour|to|tournament”)) fail?

萝らか妹 提交于 2019-12-22 04:33:06
问题 In http://llvm.org/svn/llvm-project/libcxx/trunk/test/re/re.alg/re.alg.match/ecma.pass.cpp, the following test exists: std::cmatch m; const char s[] = "tournament"; assert(!std::regex_match(s, m, std::regex("tour|to|tournament"))); assert(m.size() == 0); Why should this match be failed? On VC++2012 and boost, the match succeeds. On Javascript of Chrome and Firefox, "tournament".match(/^(?:tour|to|tournament)$/) succeeds. Only on libc++, the match fails. 回答1: I believe the test is correct. It

Possible to enable libc++ debug checks?

这一生的挚爱 提交于 2019-12-21 23:51:13
问题 I've been wondering if it is possible to enable any debug checks for libc++. One of my favorite things about MSVC's STL is that it catches some otherwise hard to find bugs right from the get go (though I wish it were easier to disable for speed). After peeking in the headers I tried: #define _LIBCPP_DEBUG_LEVEL 2 However, this leads to build errors ('__get_db undeclared'). Any insights on whether this is a work in progress, or if there is a different expected way to enable these checks? 回答1:

xlocale broken on OS X?

末鹿安然 提交于 2019-12-21 17:36:03
问题 I have a simple program that tests converting between wchar_t and char using a series of locales passed to it on the command line. It outputs a list of the conversions that fail by printing out the locale name and the string that failed to convert. I'm building it using clang and libc++. My understanding is that libc++'s named locale support is provided by the xlocale library on OS X. I'm seeing some unexpected failures, as well as some instances where conversion should fail, but doesn't.

Difference in stringstream behavior for void* type using libc++ and libstdc++

隐身守侯 提交于 2019-12-19 06:19:43
问题 The following test program returns different results depending on whether I'm using libc++ or libstdc++. #include <sstream> #include <iostream> int main() { int a = 0; void* optr = &a; void* iptr; std::stringstream ss; ss << optr; std::cout << ss.str() << '\n'; ss >> iptr; std::cout << iptr << '\n'; return 0; } I'm using the following version of clang from Xcode 5 on OSX 10.9.2 $ xcrun clang++ --version Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple

Using clang with libc++ and c++11 from the command line with mac os x

拟墨画扇 提交于 2019-12-18 15:48:13
问题 I am having trouble getting even a simple hello world to compile with clang if I enable c++11 and libc++. For example the following code #include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; } Produces the following output from the compile when I run clang++ -std=c++11 -stdlib=libc++ main.cpp In file included from main.cpp:1: In file included from /usr/bin/../lib/c++/v1/iostream:38: In file included from /usr/bin/../lib/c++/v1/ios:216: In file included from