libstdc++

In Xcode 4.5, what is “Compiler Default” for “C++ Standard Library” and “C++ Language Dialect”?

大城市里の小女人 提交于 2019-11-29 05:38:15
问题 What is the value of "Compiler Default" for "C++ Standard Library" and "C++ Language Dialect" in Xcode 4.5? My guess is libstdc++ and GNU++98, but it would be nice to have clarification. From the Xcode 4.5 release notes: Projects created using this Xcode release use the new libc++ implementation of the standard C++ library. The libc++ library is available only on iOS 5.0 and later and OS X 10.7 and later. 12221787 To enable deployment on earlier releases of iOS and OS X in your project, set

C++11 backwards compatibility

廉价感情. 提交于 2019-11-29 00:44:19
问题 Is there anything from c++11 that I can use and expect compiled binaries to run on older systems? How can I tell which parts of c++11 are a part of the libstdc++.so and what actually gets compiled into the binary? Maybe I don't fully understand how such things work. Does c++11 break ABI compliance with older libraries? An example for clarity: Say I compile a program that uses auto and the new range based for loop. These things seem like they should work on systems with old c++ runtimes

How to avoid the error: terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid

北战南征 提交于 2019-11-29 00:27:44
问题 if(player!=NULL) player->shuffled(); I do such things to avoid passing a null reference to a string constructor, but when compiling it still comes to error. 回答1: Somewhere, somehow, you're calling the std::string constructor with the const char* value NULL. To avoid the problem. Don't do that. 来源: https://stackoverflow.com/questions/11705886/how-to-avoid-the-error-terminate-called-after-throwing-an-instance-of-stdlog

Does C++11 require allocators to be default constructible, libstdc++ and libc++ disagree?

萝らか妹 提交于 2019-11-28 23:46:28
Using a slightly modified version of Howard Hinnants's C++11 stack allocator which is documented here and here , with std::basic_string and compiling with gcc which is using libstdc++ , the following example ( see it live ): const unsigned int N = 200; arena<N> a; short_alloc<char, N> ac(a) ; std::basic_string<char,std::char_traits<char>,short_alloc<char, N>> empty(ac); gives the following error( amongst others ): error: no matching function for call to 'short_alloc<char, 200ul>::short_alloc()' if (__n == 0 && __a == _Alloc()) ^ However it works without error when compiling with clang and

How do I perform a pairwise binary operation between the elements of two containers?

我的未来我决定 提交于 2019-11-28 23:17:41
Suppose I have two vectors std::vector<uint_32> a, b; that I know to be of the same size. Is there a C++11 paradigm for doing a bitwise-AND between all members of a and b , and putting the result in std::vector<uint_32> c; ? A lambda should do the trick: #include <algorithm> #include <iterator> std::transform(a.begin(), a.end(), // first b.begin(), // second std::back_inserter(c), // output [](uint32_t n, uint32_t m) { return n & m; } ); Even better, thanks to @Pavel and entirely C++98: #include <functional> std::transform(a.begin(), a.end(), b.begin(), std::back_inserter(c), std::bit_and

Risks of different GCC versions at link / run time?

倖福魔咒の 提交于 2019-11-28 18:47:30
I'm using Intel's C++ compiler, which on Linux relies on the GNU-supplied libc.so and libstdc++.so. Here's my problem. To have access to some of the newest C++11 features, I need to use the libstdc++ which ships with GCC 4.7 or higher. But I'm stuck using CentOS 6.4. On CentOS 6.4, the native version of GCC is 4.4. But using a RedHat thing called "SCL" and a package named "devtoolset-1.1", I'm able to get GCC 4.7 installed under "/opt". I set things up to be using GCC 4.7 in the manner mentioned above, I can use the newer C++11 features. So here's my question: If a user runs my program with

Implicit conversion failure from initializer list

我怕爱的太早我们不能终老 提交于 2019-11-28 18:34:43
Consider the snippet: #include <unordered_map> void foo(const std::unordered_map<int,int> &) {} int main() { foo({}); } This fails with GCC 4.9.2 with the message: map2.cpp:7:19: error: converting to ‘const std::unordered_map<int, int>’ from initializer list would use explicit constructor ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type, const hasher&, const key_equal&, const allocator_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const

Linking using g++ fails searching for -lstdc++

微笑、不失礼 提交于 2019-11-28 18:18:38
I'm trying to use someone else's Makefile to complile a very simple c++ library. The makefile is as follows: JNIFLAGS=-O2 -pthread -I/usr/lib/jvm/java-6-sun/include -I/usr/lib/jvm/java-6-sun/include/linux all: rm -f ../dist/libUtils.so g++ $(JNIFLAGS) -c -m32 -o com_markets_utils_dates_NativeTime.o com_markets_utils_dates_NativeTime.cpp g++ $(JNIFLAGS) -c -m32 -o DateUtil.o DateUtil.cpp g++ -pthread -m32 -shared -fPIC -o ../dist/libUtils.so DateUtil.cpp g++ -pthread -m32 -shared -fPIC -o ../dist/libNativeTime.so DateUtil.o com_markets_utils_dates_NativeTime.o This compiles fine, but the linker

std::istream operator exception reset / not thrown

巧了我就是萌 提交于 2019-11-28 13:58:03
I'm not sure about how to use std::istream::exception according to the standard , to let std::istream::operator>> throw an exception if it can't read the input into a variable, e.g. double. The following code has different behavior with clang/libc++ and gcc/libstdc++: #include <iostream> #include <cassert> int main () { double foo,bar; std::istream& is = std::cin; is.exceptions(std::istream::failbit); is >> foo; //throws exception as expected with gcc/libstdc++ with input "ASD" std::cout << foo; is >> bar; std::cout << bar; assert(is); //failed with clang/libc++ after input "ASD" std::cout <<

What Effect Would LWG2349 Have?

家住魔仙堡 提交于 2019-11-28 13:35:12
While libstdc++ does not, libc++ does follow the standard which states that passing ios_base::failbit to basic_istream::exceptions has no effect on formatted input. For example this code: istringstream is{"ASD"}; double foo; is.exceptions(istream::failbit); try { is >> foo; cout << foo << endl; } catch(ios_base::failure& fail) { cout << "ouch\n"; } Would result in: "ouch" on libstdc++ "0" on libc++ My reading of LWG2349 is that it would cause basic_istream to not throw on any formatted input. For example LWG2349 proposes a change to the standard's 27.7.2.3 [istream]/1 which was cited with