I just read the Boost.Hana tutorial but unfortunately got stuck very early. Could anybody explain to me why to_json
for integers is implemented the way it is:
template <typename T>
auto to_json(T const& x) -> decltype(std::to_string(x)) {
return std::to_string(x);
}
I thought that the return type would be simply equivalent to std::string
but it is not. If you replace it with std::string
the compiler complains about ambiguous function call. What is the difference between std::string and decltype(std::to_string(x))?