g++4.9

no matching function for call to ‘regex_search(…)'

泪湿孤枕 提交于 2019-12-22 04:38:21
问题 Given an old-style const char * pointer and a length, is there a way to call std::regex_search() on it without first copying the contents of the buffer into a std::string ? Here is a simple example of the problem I have: #include <regex> int main() { const char *text = "123 foobar 456"; const size_t len = strlen(text); const std::regex rx(" (.+)bar"); std::smatch what; std::regex_search( text, text+len, what, rx); // <- problematic line return 0; } I thought the 5th std::regex_search() that

Modify g++ library path

限于喜欢 提交于 2019-12-20 05:50:35
问题 I recently installed gcc 4.9.2 and found a problem when linking with libs. The output for search path: install: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/ programs: =/usr/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/x86_64-unknown

How to specify type of a constexpr function returning a class (without resorting to auto keyword)

a 夏天 提交于 2019-12-13 09:56:06
问题 Basically in below I want to see if I can get around having to use auto keyword Suppose that we have the following piece of code [works with g++ 4.9.2 (Ubuntu 4.9.2-10ubuntu13) & clang version 3.6.0] : //g++ -std=c++14 test.cpp //test.cpp #include <iostream> using namespace std; template<typename T> constexpr auto create() { class test { public: int i; virtual int get(){ return 123; } } r; return r; } auto v = create<int>(); int main(void){ cout<<v.get()<<endl; } How can I specify the type of

Returning a class from a constexpr function requires virtual keyword with g++

浪尽此生 提交于 2019-12-08 02:14:58
问题 Hi the following program works with g++ 4.9.2 (Ubuntu 4.9.2-10ubuntu13) but the virtual keyword is required for the function get : //g++ -std=c++14 test.cpp //test.cpp #include <iostream> using namespace std; template<typename T> constexpr auto create() { class test { public: int i; virtual int get(){ return 123; } } r; return r; } auto v = create<int>(); int main(void){ cout<<v.get()<<endl; } If I omit the virtual keyword, I get the following error : test.cpp: In instantiation of ‘constexpr

What's the right way to work with a different C++ compiler in a CDT project?

匆匆过客 提交于 2019-12-07 06:27:17
问题 I use Eclipse CDT Mars.2 (and Neon RC), on Linux. My distribution's default C++ compiler is GCC 5.3.1, but for some of my work I use GCC 4.9.3. I would like everything regarding my project to use GCC 4.9.3: The tool discovery, the C++ standard library, the include file paths, the indexer, the preprocessing - all of it. What's the right way to do this? It seems Eclipse has rather byzantine "providers" and "toolchains" configurations and I do not want to make settings I won't be able to undo

Returning a class from a constexpr function requires virtual keyword with g++

。_饼干妹妹 提交于 2019-12-06 13:26:53
Hi the following program works with g++ 4.9.2 (Ubuntu 4.9.2-10ubuntu13) but the virtual keyword is required for the function get : //g++ -std=c++14 test.cpp //test.cpp #include <iostream> using namespace std; template<typename T> constexpr auto create() { class test { public: int i; virtual int get(){ return 123; } } r; return r; } auto v = create<int>(); int main(void){ cout<<v.get()<<endl; } If I omit the virtual keyword, I get the following error : test.cpp: In instantiation of ‘constexpr auto create() [with T = int]’: test.cpp:18:22: required from here test.cpp:16:1: error: body of

Implicit cast from const string to bool [duplicate]

女生的网名这么多〃 提交于 2019-12-06 04:01:14
问题 This question already has answers here : Why is there an implicit type conversion from pointers to bool in C++? (3 answers) Closed 2 years ago . I have the following code: #include <iostream> #include <string> void foo(bool a) { std::cout << "bool" << std::endl; } void foo(long long int a) { std::cout << "long long int" << std::endl; } void foo(const std::string& a) { std::cout << "string" << std::endl; } int main(int argc, char* args[]) { foo("1"); return 0; } When executing I get this

What's the right way to work with a different C++ compiler in a CDT project?

江枫思渺然 提交于 2019-12-05 08:32:31
I use Eclipse CDT Mars.2 (and Neon RC), on Linux. My distribution's default C++ compiler is GCC 5.3.1, but for some of my work I use GCC 4.9.3. I would like everything regarding my project to use GCC 4.9.3: The tool discovery, the C++ standard library, the include file paths, the indexer, the preprocessing - all of it. What's the right way to do this? It seems Eclipse has rather byzantine "providers" and "toolchains" configurations and I do not want to make settings I won't be able to undo later... Note: I did try to replace ${COMMAND} with /usr/bin/g++-4.9 in some of the Preprocessor Includes

Modify g++ library path

时光怂恿深爱的人放手 提交于 2019-12-02 11:43:35
I recently installed gcc 4.9.2 and found a problem when linking with libs. The output for search path: install: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/ programs: =/usr/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/bin/x86

no matching function for call to ‘regex_search(…)'

早过忘川 提交于 2019-11-29 10:43:21
Given an old-style const char * pointer and a length, is there a way to call std::regex_search() on it without first copying the contents of the buffer into a std::string ? Here is a simple example of the problem I have: #include <regex> int main() { const char *text = "123 foobar 456"; const size_t len = strlen(text); const std::regex rx(" (.+)bar"); std::smatch what; std::regex_search( text, text+len, what, rx); // <- problematic line return 0; } I thought the 5th std::regex_search() that takes two iterators is what I need, but I'm not fully understanding how to convert pointers to iterators