gcc4.8

Strange results when using C++11 regexp with gcc 4.8.2 (but works with Boost regexp) [duplicate]

大兔子大兔子 提交于 2019-12-17 16:37:07
问题 This question already has answers here : Is gcc 4.8 or earlier buggy about regular expressions? (3 answers) Closed 5 years ago . I tried to use C++11's regular expression but failed even in trivial examples. From the outside, it seems to only compare the strings, for example: std::regex_match(std::string{""}, std::regex{"a?"}) // false (???) std::regex_match(std::string{"a?"}, std::regex{"a?"}) // true (???) In contrast, the Boost's regexp library behaves as I would have expected: boost:

Move operations for a class with a thread as member variable

别说谁变了你拦得住时间么 提交于 2019-12-12 03:44:34
问题 I'm trying to expand with what some people helped me here Call function inside a lambda passed to a thread so my worker class can support a move constructor and a move operator= , but I have the problem that my class is binding this by copy (or reference) to the thread so it can access the class values. Which are several atomic<bool> , a condition_variable and a mutex . But when I try to move it since the thread is bound to the other condition variable, mutex and atomic s, anything I do on it

Anything other than -Ofast causes “undefined reference” error

自作多情 提交于 2019-12-11 09:34:41
问题 I have a C program which includes math.h and makes use of the sqrt function from that header. Very strangely, when I do not pass the -Ofast flag, my code does not compile. If I use the following to compile my code: gcc -std=c99 foo.c Either by itself, or add any of -O1 , -O2 or -Os (those are uppercase O's) to that command, I get the following error: /tmp/ccAcT2Bz.o: In function `sum_of_divisors': foo.c:(.text+0xb): undefined reference to `sqrt' collect2: error: ld returned 1 exit status -O3

How do I get a homebrewed version of GDB working on Mac OS X Nr. 2?

故事扮演 提交于 2019-12-11 02:46:01
问题 I installed XCode 5.1 with clang I installed gcc 4.8 via homebrew Installed gdb 7.7.1 via homebrew Using OSX 10.9.3 I compile my c++ source in eclipse kepler with a Makefile using g++-4.8 and try to debug it but when reaching a breakpoint I can't see any variables just like in this question: GDB says "no symbol table," but nm shows file has debug symbols I followed the suggestions of @Tom Tromey in the suggestions section of that question to use set complaints 10000 in gdb and then load the

How to update to mingw-gcc 4.8.2?

拈花ヽ惹草 提交于 2019-12-10 12:49:50
问题 I want to use Regular expression in c++11 and gcc 4.8.2 supports it. But the MinGW installer only supports up to gcc 4.8.1. How can I update it to gcc 4.8.2? 回答1: You can manually install it yourself. There's a MinGW-w64 distribution for 4.8.2 available here. You'll need 7zip to extract the file contents. After you unzip it to a location of you're choosing just add the bin subdirectory from there to your environment path and you should be good to go. For example, if you extracted the

Getting a unique_ptr out of a priority queue

依然范特西╮ 提交于 2019-12-09 18:18:25
问题 I am maintaining a set of unique_ptr instances in a priority_queue . At some point, I want to get the first element and remove it from the queue. However, this always produces a compiler error. See sample code below. int main () { std::priority_queue<std::unique_ptr<int>> queue; queue.push(std::unique_ptr<int>(new int(42))); std::unique_ptr<int> myInt = std::move(queue.top()); return 1; } This produces the following compiler error (gcc 4.8.0): uptrtest.cpp: In function ‘int main()’: uptrtest

constexpr function not calculate value in compile time

橙三吉。 提交于 2019-12-07 02:59:30
问题 I want to compare meta programming and use of constexpr in c++0x. then I write a fib function in both model. when I use meta programming model, answer print out very fast because it calculated in compile time. but when I use constexpr funcion it calculate value in run time, not in compile time. I using g++( gcc ) 4.8 .can any body help me? #include <iostream> using namespace std; #define NUM 42 template <unsigned int N> struct Fibonacci { enum { value = Fibonacci<N - 1>::value + Fibonacci<N -

constexpr function not calculate value in compile time

旧街凉风 提交于 2019-12-05 06:39:18
I want to compare meta programming and use of constexpr in c++0x. then I write a fib function in both model. when I use meta programming model, answer print out very fast because it calculated in compile time. but when I use constexpr funcion it calculate value in run time, not in compile time. I using g++( gcc ) 4.8 .can any body help me? #include <iostream> using namespace std; #define NUM 42 template <unsigned int N> struct Fibonacci { enum { value = Fibonacci<N - 1>::value + Fibonacci<N - 2>::value }; }; template <> struct Fibonacci<1> { enum { value = 1 }; }; template <> struct Fibonacci

constexpr versus template, pow function

匆匆过客 提交于 2019-12-05 02:55:38
I am experimenting new feature of the c++11, constexpr especially. If I want to code a pow with template I will simply do: //pow template<class T, std::size_t n> struct helper_pow{ inline static T pow(T const& a){ return a*helper_pow<T,n-1>::pow(a); } }; //final specialization pow template<class T> struct helper_pow<T,0>{ inline static T pow(T const& a){ return 1; } }; Now if I call my function into my code simply by: pow<double,5>(a) // where a is double the corresponding assembly will be (gcc 4.8.0, -O2): movapd %xmm0, %xmm1 movsd %xmm0, 24(%rsp) mulsd %xmm0, %xmm1 movq %rbx, %rdi mulsd

Call function inside a lambda passed to a thread

馋奶兔 提交于 2019-12-04 02:15:37
问题 I'm trying to create a object that can be given a function and its parameters to his constructor. This class will then call the given function inside a lambda that is instead passed to a thread. Something along the lines of class worker { public: template <class Fn, class... Args> explicit worker(Fn f, Args ... args) { t = std::thread([&]() -> void { f(args...); }); } private: std::thread t; }; int main() { worker t([]() -> void { for (size_t i = 0; i < 100; i++) std::cout << i << std::endl;