libstdc++

C++11 random number distributions are not consistent across platforms — what alternatives are there?

◇◆丶佛笑我妖孽 提交于 2019-11-27 22:58:02
I'm looking for a set of portable distributions for the standard C++11 engines like `std::mt19937' (see http://en.cppreference.com/w/cpp/numeric/random ). The engine implementations perform consistently (i.e. same sequence generated on different platforms – tested with Clang and MSVC), but the distributions seem to be implemented differently on the different platforms. So, even though the engines produce the same sequence, it seems that a distribution (for example, std::normal_distribution<double> ) does not use the same number of samples (i.e. produces different results) on the different

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

落爺英雄遲暮 提交于 2019-11-27 21:12:20
问题 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; ? 回答1: 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:

Should I use libc++ or libstdc++? [closed]

喜你入骨 提交于 2019-11-27 17:22:21
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++? Jonathan Wakely I would use the native library for each OS i.e. libstdc++ on GNU/Linux and libc++ on Mac OS X. libc++ is not 100% complete on GNU/Linux, and there's no real advantage to using it when libstdc++ is more complete. Also, if you want to link to any other libraries written in C++ they will almost certainly have been built with libstdc++ so you'll need to link with that too to use them. More info here about the completeness of

How to statically link libstdc++

[亡魂溺海] 提交于 2019-11-27 16:17:43
问题 I am trying to get my program working in another machine where libstdc++ versions is different. I am developing and compiling it on netbeans. I have specified the option -static-libstdc++ but the program continues trying to load libstdc++.so.6 in the local machine. How can I get a fully static libstdc++ link? Thanks. 回答1: Not sure of the exact circumstances here, but I ran into a similar problem just now with different versions of Mac OS X and gcc. I worked around it by copying the actual

Where does the __1 symbol come from when using LLVM's libc++?

左心房为你撑大大i 提交于 2019-11-27 14:48:48
I see a fair amount of questions like Apple Mach-O Linker (Id) Error and Undefined symbols in cryptopp at IOS 64-bit project . The problem is usually described as: Undefined symbols for architecture i386: "std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()", referenced from: cv::gpu::error(char const*, char const*, int, char const*) in opencv2(gpumat.o) The problem often reduces to mixing/matching -stdlib=libc++ (LLVM C++ runtime) and -stdlib=libstdc++ (GNU C++ runtime). The LLVM C++ runtime ( libc++ ) has an __1 decoration symbol, but the GNU C++ runtime libstdc++ lacks the

Risks of different GCC versions at link / run time?

北战南征 提交于 2019-11-27 11:39:50
问题 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

Implicit conversion failure from initializer list

一曲冷凌霜 提交于 2019-11-27 11:28:26
问题 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;

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

[亡魂溺海] 提交于 2019-11-27 11:13:00
问题 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 ..

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

本秂侑毒 提交于 2019-11-27 10:27:16
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 against libstdc++ (coming from MacPorts). In doing so, I got linking errors, since the headers of the legacy libraries using, e.g., std::string , required to be resolved against the std::__1::basic_string (i.e., the libc++ implementation of std::string ) instead of the std::basic_string implementation. Is there a way to mix the two libraries in

C++ project compiled with modern compiler, but linked against outdated libstdc++

天涯浪子 提交于 2019-11-27 09:32:09
Consider the situation when a C++ project is built and shipped within a Centos 7 virtual machine or container. Default gcc for Centos 7 is 4.8 . In order to allow developers to use modern C++, the more recent version of gcc (for example, 6.3 ) is installed into Centos 7 which runs as a CI server. This provides -std=c++14 support. [builder@f7279ae9f33f build (master %)]$ /usr/bin/c++ -v 2>&1 | grep version gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) [builder@f7279ae9f33f build (master %)]$ /opt/rh/devtoolset-6/root/usr/bin/c++ -v 2>&1 | grep version gcc version 6.3.1 20170216 (Red Hat 6