libstdc++

Force use of locks inside std::atomic during debugging with libstdc++

江枫思渺然 提交于 2019-12-10 14:24:54
问题 I've done a bit of a google and can't seem to turn up a GCC option or libstdc++ macro for this. Is it possible to force the use of locking internally on all the std::atomic template specializations. On some platforms some of the specializations are locking anyway, so it certainly seems like a feasible option. In the past I've found the use of std::atomic to be very painful when debugging data-races with tools such as Valgrind ( Helgrind or DRD ) due to the enormous number of false positives.

Should sorting algorithm pass same element in the comparison function

不羁岁月 提交于 2019-12-10 13:31:45
问题 The std::sort of libcxx (llvm version of c++ standard library) calls the comparison predicate with the same element i.e., both the arguments of comparison functor refer to the same position in the sequence to be sorted. A reduced example to illustrate the point. $ cat a.cc #include <algorithm> #include <vector> #include <cassert> int main(int argc, char** argv) { int size = 100; std::vector<int> v(size); // Elements in v are unique. for (int i = 0; i < size; ++i) v[i] = i; std::sort(v.begin()

c++ libstd compute sin and cos simultaneously

青春壹個敷衍的年華 提交于 2019-12-10 12:34:00
问题 In C library math.h , there was a sincos function which was pretty efficient, because it computed both sine and cosine in a time closer to a single call to sin() or cos() than to the total time of calling both. Is there such function in C++ standard library? 回答1: Is there no such function in c++ standard library? No, unfortunately there isn't. In C library math.h, there was a sincos function On Linux, it is available as GNU Extension. It's not standard in C either. 回答2: Just use sin and cos

The program cannot find correct version of glibc/libstdc++, although it was statically linked

旧街凉风 提交于 2019-12-10 04:34:06
问题 I am trying to link my program statically with glibc, because version of the glibc on the target machine is pretty much unpredictable. I used linker flags -static-libgcc and -static-libstdc++ and it worked fine. The executable is big, but I can live with it. Unfortunately, when I run my executable on the target machine (it is named 'mytest' in the example below) I get the following error: ./mytest: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by libboost_log.so.1.53

istream eof discrepancy between libc++ and libstdc++

为君一笑 提交于 2019-12-10 02:56:45
问题 The following (toy) program returns different things when linked against libstdc++ and libc++. Is this a bug in libc++ or do I not understand how istream eof() works? I have tried running it using g++ on linux and mac os x and clang on mac os x, with and without -std=c++0x. It was my impression that eof() does not return true until an attempt to read (by get() or something else) actually fails. This is how libstdc++ behaves, but not how libc++ behaves. #include <iostream> #include <sstream>

Test whether libstdc++'s version uses a C++11-compliant std::string

喜欢而已 提交于 2019-12-10 01:50:31
问题 I'm writing some C++11 code that makes assumptions about the nature of std::string that are valid, but represent behavior that was changed in C++11. In the earlier days, libstdc++'s basic_string implementation conformed to the 98/03 requirements, but not to the more strict C++11 requirements. As I understand it, libstdc++ has fixed the issues around basic_string . The problem is that there are many versions of the library that people use which do not implement this fix. And my code may

Porting a C++ application to android

我们两清 提交于 2019-12-09 16:31:59
问题 Is it possible to port a C++ application which uses the STL extensively to Android? I understand that currently the NDK does not support this, but is there any effort (open source or otherwise) underway to achieve this? If not is there a way to cross compile libstdc++ for Android? UPDATE: Ndk Revision 5 promises a default STL implementation based on STLport. http://android-developers.blogspot.com/2011/01/gingerbread-ndk-awesomeness.html Read this official NDK blog post, http://developer

Disabling bounds checking for c++ vectors

旧城冷巷雨未停 提交于 2019-12-09 05:37:25
问题 With stl::vector: vector<int> v(1); v[0]=1; // No bounds checking v.at(0)=1; // Bounds checking Is there a way to disable bounds checking without having to rewrite all at() as [] ? I am using the GNU Standard C++ Library. Edit : I changed at() to [] in the area where I suspected a bottleneck, and it significantly reduced the computation time. However, since I iterate between developing the code and running experiments with it, I would like to enable bounds checking during development and

Have I misunderstood the scope of this default argument shared_ptr?

北慕城南 提交于 2019-12-08 19:25:25
问题 Take a look at this: #include <iostream> #include <memory> using Foo = int; using FooPtr = std::shared_ptr<Foo>; FooPtr makeFoo() { FooPtr f{ new Foo(), [](Foo* ptr) { delete ptr; std::cerr << "!\n"; } }; return f; } void bar(FooPtr p = {}) { p = makeFoo(); } int main() { bar(); } // Expected output: '!' // Failure case: no output (deleter not invoked?) I expected the shared_ptr deleter to be called when bar() returns, and on my 64-bit CentOS 7 system using GCC 4.8.5, it does. However, on my

Macports on OSX 10.9 - compile opencv with libstdc++

我是研究僧i 提交于 2019-12-08 12:46:37
问题 My situation is very similar to what's discussed in this thread. The reason I want to do this is that I am using OpenCV with CUDA 6.0, but CUDA is currently linked against libstdc++. I followed the answer that suggested putting the flag -stdlib=libstdc++ as well as the other approach where we set CXX and CXXFLAGS but as it was being commented: Macports did not seem to acknowledge the flags and still built with libc++ instead of intended libstdc++. I would like to comment on that thread to ask