<string> Support

#include <boost/int256/string.hpp>

The following are functions analogous to those found in <string> for the built-in integer types.

#include <boost/int256/string.hpp>

namespace boost {
namespace int256 {

// Constrained to T being uint256 or int256.
template <typename T>
std::enable_if_t<std::is_same<T, uint256>::value || std::is_same<T, int256>::value, std::string>
to_string(const T& value);

// Constrained to T being uint256 or int256.
template <typename T>
std::enable_if_t<std::is_same<T, uint256>::value || std::is_same<T, int256>::value, std::wstring>
to_wstring(const T& value);

} // namespace int256
} // namespace boost

to_string returns a std::string, and to_wstring returns a std::wstring, containing the decimal (base 10) representation of value, which is at most 78 characters long for uint256 and 77 plus a leading - for a negative int256. These functions may throw std::bad_alloc from the constructor of the returned string, and are host-only for that reason.

An example of how to use these functions is available on the examples page.