to_string(float) is apparently supported since c++11:
https://en.cppreference.com/w/cpp/string/basic_string/to_stringI am using GCC11 :
https://github.com/sodero/adtools/rele ... cc11.1.0-20210531-743.lhaI am trying to build:
type main.cpp
#include <iostream>
#include <string>
int main()
{
std::string x = std::to_string(22.2f);
std::cout<<x<<std::endl;
return 0;
}
4.Other:Dev/cpp11> g++ -std=c++11 -athread=native -o main main.cpp
main.cpp: In function 'int main()':
main.cpp:6:39: error: call of overloaded 'to_string(float)' is ambiguous
6 | std::string x = std::to_string(22.2f);
| ~~~~~~~~~~~~~~^~~~~~~
In file included from /Programs/SDK/gcc/include/c++/11.1.0/string:55,
from /Programs/SDK/gcc/include/c++/11.1.0/bits/locale_classes.h:40,
from /Programs/SDK/gcc/include/c++/11.1.0/bits/ios_base.h:41,
from /Programs/SDK/gcc/include/c++/11.1.0/ios:42,
from /Programs/SDK/gcc/include/c++/11.1.0/ostream:38,
from /Programs/SDK/gcc/include/c++/11.1.0/iostream:39,
from main.cpp:1:
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6649:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
6649 | to_string(int __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6660:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
6660 | to_string(unsigned __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6668:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
6668 | to_string(long __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6679:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
6679 | to_string(unsigned long __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6687:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
6687 | to_string(long long __val)
| ^~~~~~~~~
/Programs/SDK/gcc/include/c++/11.1.0/bits/basic_string.h:6699:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
6699 | to_string(unsigned long long __val)
| ^~~~~~~~~
g++ --version
g++ (adtools build 11.1.0) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Edited by rjd324 on 2022/3/17 0:18:27