After a bit more digging around I came across this on SO: https://stackoverflow.com/a/24000041/897778
Adapted for my use case I get:
namespace detail
{
template<unsigned... digits>
struct to_chars { static const char value[]; };
template<unsigned... digits>
const char to_chars<digits...>::value[] = {'{', ('0' + digits)..., '}' , 0};
template<unsigned rem, unsigned... digits>
struct explode : explode<rem / 10, rem % 10, digits...> {};
template<unsigned... digits>
struct explode<0, digits...> : to_chars<digits...> {};
}
template<unsigned num>
struct num_to_string : detail::explode<num / 10, num % 10>
{};
template <unsigned N>
void test()
{
const char* str = num_to_string<N>::value;
}
boost::mpl
was also suggested, but this code seems simpler.