gcc4.9

What is happening here in pow function?

廉价感情. 提交于 2019-11-26 14:46:01
问题 I have seen various answer here that depicts Strange behavior of pow function in C. But I Have something different to ask here. In the below code I have initialized int x = pow(10,2) and int y = pow(10,n) (int n = 2) . In first case it when I print the result it shows 100 and in the other case it comes out to be 99 . I know that pow returns double and it gets truncated on storing in int , but I want to ask why the output comes to be different. CODE1 #include<stdio.h> #include<math.h> int main

Difference between std::regex_match & std::regex_search?

孤者浪人 提交于 2019-11-26 08:54:02
问题 Below program has been written to fetch the \"Day\" information using the C++11 std::regex_match & std::regex_search. However, using the first method returns false and second method returns true (expected). I read the documentation and already existing SO question related to this, but I do not understand the difference between these two methods and when we should use either of them? Can they both be used interchangeably for any common problem? Difference between regex_match and regex_search?

Is auto as a parameter in a regular function a GCC 4.9 extension?

℡╲_俬逩灬. 提交于 2019-11-26 08:52:07
问题 gcc 4.9 allows the following code, but gcc 4.8 and clang 3.5.0 reject it. void foo(auto c) { std::cout << c.c_str(); } I get warning: ISO C++ forbids use of \'auto\' in parameter declaration [-Wpedantic] in 4.9 but in 4.8 and clang I get error: parameter declared \'auto\' . 回答1: Yes, this is an extension. It's likely to be added to C++17 as part of the 'concepts' proposal, I believe. 回答2: This is Concepts Lite speak for template<class T> void foo(T c) { std::cout << c.c_str(); } The auto just