This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename string1, typename string2> | |
struct sum_chars_count | |
{ | |
static constexpr auto sum = to_string<string1>::size + to_string<string2>::size; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace details | |
{ | |
template <typename> | |
struct string_front_impl; | |
template <char front, char ...chars> | |
struct string_front_impl<string<front, chars...>> | |
{ | |
static constexpr auto value = front; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename, int sign = 1, int current_val = 0> | |
struct string_to_int_impl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <int sign, int current_val> | |
struct string_to_int_impl<string<>, sign, current_val> | |
{ | |
static constexpr auto value = sign * current_val; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <int sign, int current_val, char current_char, char ...chars> | |
struct string_to_int_impl<string<current_char, chars...>, sign, current_val> | |
{ | |
static constexpr auto nex_val = current_val * 10 + (current_char - '0'); | |
static constexpr auto value = string_to_int_impl<string<chars...>, sign, nex_val>::value; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <int sign, int current_val, char current_char, char ...chars> | |
struct string_to_int_impl<string<'-', current_char, chars...>, sign, current_val> | |
{ | |
static constexpr auto nex_val = current_val * 10 + (current_char - '0'); | |
static constexpr auto value = string_to_int_impl<string<chars...>, -1, nex_val>::value; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string_to_int_impl< string< '-', '2', '6', '3' >, 1, 0> // this will hit 3rd specialization | |
string_to_int_impl< string< '6', '3' >, -1, 2> // this will hit the 2nd | |
string_to_int_impl< string< '3' >, -1, 26> // this will hit the 2nd | |
string_to_int_impl< string<>, -1, 263> // this will hit first one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <int value, bool end, typename sign_str, typename current_string = string<>> | |
struct string_from_int_impl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename sign_str, typename current_string> | |
struct string_from_int_impl<0, sign_str, true, current_string> | |
{ | |
using type = string_merge<sign_str, current_string>; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <int value, typename sign_str, char ...chars> | |
struct string_from_int_impl<value, sign_str, false, string<chars...>> | |
{ | |
using type = typename string_from_int_impl< | |
value/10, | |
sign_str, | |
value/10 == 0, | |
string<value % 10 + '0', chars...>>::type; | |
}; |