to_string() invalid for g++ 4.7.2

Hi, according to
http://v2.cplusplus.com/forum/general/74945/
, I already put -std=c++11 when compiling mingw g++ 4.7.2.

but compiler still warns me

test2.cpp:14:31: error: 'to_string' is not a member of 'std'

Please let me know what should I do?
Last edited on
Did you include <string>?
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52015

A work around:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <string>
#include <sstream>

namespace my
{
    template < typename T > std::string to_string( const T& v )
    {
        std::ostringstream stm ;
        return ( stm << v ) ? stm.str() : "{*** error ***}" ;
    }
}

int main()
{
    std::cout << my::to_string(78) << '\n' ;
}


http://liveworkspace.org/code/3f1mPe$0
Topic archived. No new replies allowed.