Hi,
I have a strange problem. When I try to use std::to_string() I get the following error:
$ g++ -o test_to_string test_to_string.cc test_to_string.cc: In function ‘int main()’: test_to_string.cc:7:28: error: ‘to_string’ is not a member of ‘std’ std::cout << "Five: " << std::to_string(5) << std::endl; ^
Here is my test file (test_to_string.cc):
----------8<----------8<---------- #include <iostream> #include <string>
int main() { std::cout << "Five: " << std::to_string(5) << std::endl; return 0; } ----------8<----------8<----------
A quick search does not point me to any error on my part[1]. Is there a bug in Fedora GCC?
Thanks for any thoughts.
[1] http://en.cppreference.com/w/cpp/string/basic_string/to_string
On Tue, Oct 08, 2013 at 09:20:58AM +0200, Suvayu Ali wrote:
I have a strange problem. When I try to use std::to_string() I get the following error:
$ g++ -o test_to_string test_to_string.cc test_to_string.cc: In function ‘int main()’: test_to_string.cc:7:28: error: ‘to_string’ is not a member of ‘std’ std::cout << "Five: " << std::to_string(5) << std::endl;
Okay, found my problem. I have to explicitly choose C++11. I did not realise C++11 was not the default. Any ideas why?
On 10/08/2013 08:30 AM, Suvayu Ali wrote:
Okay, found my problem. I have to explicitly choose C++11. I did not realise C++11 was not the default. Any ideas why?
We (GCC maintainers) tend to change defaults when it's what the majority of users want. For most people C++11 is still experimental. Changing the default language is risky because it breaks build scripts.
Andrew.
Hi Andrew and Mamoru,
On Tue, Oct 08, 2013 at 08:57:29AM +0100, Andrew Haley wrote:
On 10/08/2013 08:30 AM, Suvayu Ali wrote:
Okay, found my problem. I have to explicitly choose C++11. I did not realise C++11 was not the default. Any ideas why?
We (GCC maintainers) tend to change defaults when it's what the majority of users want. For most people C++11 is still experimental. Changing the default language is risky because it breaks build scripts.
Thank you for both your answers. Both make sense. :)
Cheers,