using std::to_string
std::string a = to_string(some_object);
#include<iostream>
template< typename T>std::string as_string(T &&o) { using std::to_string; returnto_string(std::forward<T>(o));}
classA {};
std::string to_string(constA &a) { return"hello";}
intmain() { std::cout << as_string(1) << as_string(A{}); return0;}--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2e3b84ef-15c8-42d4-a5de-5ce9ee3c078c%40isocpp.org.
The issue of using std::to_string as a full name creates an issue when I want to do it with a custom type. I would have to use a separate function for that. This might be an issue in generic code, where I am forced to have using std::to_string each time I want to do that.As for the issue with conflicts, if it is standardized, as_string will be a part of std namespace, the only way it can conflict with some existing function is if it was an unqualified call. This is an issue for any function which can be added to the standard library.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ae38a92d-b554-4219-9cd6-5a5248512c1e%40isocpp.org.
The issue of using std::to_string as a full name creates an issue when I want to do it with a custom type. I would have to use a separate function for that. This might be an issue in generic code, where I am forced to have using std::to_string each time I want to do that.As for the issue with conflicts, if it is standardized, as_string will be a part of std namespace, the only way it can conflict with some existing function is if it was an unqualified call. This is an issue for any function which can be added to the standard library.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ae38a92d-b554-4219-9cd6-5a5248512c1e%40isocpp.org.