mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add _ placeholder User-defined literals
This commit is contained in:
parent
50f2ba6e31
commit
2f86a59273
7 changed files with 188 additions and 116 deletions
22
sprout/detail/digits_to_int.hpp
Normal file
22
sprout/detail/digits_to_int.hpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef SPROUT_DETAIL_DIGITS_TO_INT_HPP
|
||||
#define SPROUT_DETAIL_DIGITS_TO_INT_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename IntType, char... Chars>
|
||||
struct digits_to_int;
|
||||
template<typename IntType, char C>
|
||||
struct digits_to_int<IntType, C>
|
||||
: public std::integral_constant<IntType, IntType(C - 48)>
|
||||
{};
|
||||
template<typename IntType, char Head, char... Tail>
|
||||
struct digits_to_int<IntType, Head, Tail...>
|
||||
: public std::integral_constant<IntType, 10 * IntType(Head - 48) + sprout::detail::digits_to_int<IntType, Tail...>::value>
|
||||
{};
|
||||
} // namespace detail
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_DETAIL_DIGITS_TO_INT_HPP
|
Loading…
Add table
Add a link
Reference in a new issue