#pragma once #include #include #include #include namespace OpenVic::ConstexprIntToStr { template constexpr decltype(auto) append_sequence(std::integer_sequence, std::integer_sequence) { return std::integer_sequence {}; } template struct string_sequence_to_view; template struct string_sequence_to_view> { static constexpr decltype(auto) get() { return std::string_view { c_str }; } static constexpr const char c_str[] { chars..., char {} }; }; template constexpr decltype(auto) integer_to_string_sequence() { constexpr auto digits = []() { return "0123456789abcdefghijklmnopqrstuvwxyz"; }; constexpr std::size_t remainder = value % 10; constexpr std::size_t next_value = value / 10; if constexpr (next_value != 0) { return append_sequence(integer_to_string_sequence(), std::integer_sequence {}); } else { return std::integer_sequence {}; } } template constexpr std::string_view make_string() { return string_sequence_to_view())> {}.c_str; } template constexpr auto generate_itosv_array(std::integer_sequence) { return std::array { make_string()... }; } // Make array of N string views, countings up from 0 to N - 1 template constexpr auto make_itosv_array() { return generate_itosv_array(std::make_integer_sequence()); } }