mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
add bool_constant [N4334]
This commit is contained in:
parent
fbb95d9068
commit
a1f6d6ffc3
35 changed files with 198 additions and 106 deletions
|
@ -43,7 +43,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct is_found_via_adl
|
||||
: public sprout::integral_constant<bool, !sprout::is_not_found_via_adl<T>::value>
|
||||
: public sprout::bool_constant<!sprout::is_not_found_via_adl<T>::value>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
|
|
|
@ -91,8 +91,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Container>
|
||||
struct has_container_nosy_iterator
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::detail::has_iterator<Container>::value
|
||||
|| sprout::detail::has_const_iterator<Container>::value
|
||||
>
|
||||
|
@ -102,8 +101,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Container>
|
||||
struct has_container_nosy_value_type
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::detail::has_value_type<Container>::value
|
||||
|| sprout::detail::has_container_nosy_iterator<Container>::value
|
||||
>
|
||||
|
@ -113,8 +111,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Container>
|
||||
struct has_container_nosy_static_size
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::detail::has_static_size<Container>::value
|
||||
|| sprout::detail::is_array_like<Container>::value
|
||||
>
|
||||
|
|
|
@ -20,8 +20,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Container>
|
||||
struct is_sub_container
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
!std::is_same<typename sprout::containers::internal<Container>::type, Container&&>::value
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct has_alpha
|
||||
: public sprout::integral_constant<bool, (sprout::darkroom::access::size<T>::value >= 4)>
|
||||
: public sprout::bool_constant<(sprout::darkroom::access::size<T>::value >= 4)>
|
||||
{};
|
||||
|
||||
//
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct has_is_from_inside
|
||||
: public sprout::integral_constant<bool, (sprout::darkroom::access::size<T>::value >= 6)>
|
||||
: public sprout::bool_constant<(sprout::darkroom::access::size<T>::value >= 6)>
|
||||
{};
|
||||
|
||||
//
|
||||
|
|
|
@ -34,19 +34,19 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct has_color
|
||||
: public sprout::integral_constant<bool, (sprout::darkroom::access::size<T>::value >= 1)>
|
||||
: public sprout::bool_constant<(sprout::darkroom::access::size<T>::value >= 1)>
|
||||
{};
|
||||
template<typename T>
|
||||
struct has_reflection
|
||||
: public sprout::integral_constant<bool, (sprout::darkroom::access::size<T>::value >= 2)>
|
||||
: public sprout::bool_constant<(sprout::darkroom::access::size<T>::value >= 2)>
|
||||
{};
|
||||
template<typename T>
|
||||
struct has_alpha
|
||||
: public sprout::integral_constant<bool, (sprout::darkroom::access::size<T>::value >= 3)>
|
||||
: public sprout::bool_constant<(sprout::darkroom::access::size<T>::value >= 3)>
|
||||
{};
|
||||
template<typename T>
|
||||
struct has_refraction
|
||||
: public sprout::integral_constant<bool, (sprout::darkroom::access::size<T>::value >= 4)>
|
||||
: public sprout::bool_constant<(sprout::darkroom::access::size<T>::value >= 4)>
|
||||
{};
|
||||
|
||||
//
|
||||
|
|
|
@ -16,8 +16,7 @@ namespace sprout {
|
|||
namespace detail {
|
||||
template<typename CharType>
|
||||
struct is_char_type_of_consecutive_digits
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
SPROUT_CHAR_LITERAL('0', CharType) + 1 == SPROUT_CHAR_LITERAL('1', CharType)
|
||||
&& SPROUT_CHAR_LITERAL('1', CharType) + 1 == SPROUT_CHAR_LITERAL('2', CharType)
|
||||
&& SPROUT_CHAR_LITERAL('2', CharType) + 1 == SPROUT_CHAR_LITERAL('3', CharType)
|
||||
|
@ -44,8 +43,7 @@ namespace sprout {
|
|||
|
||||
template<typename CharType>
|
||||
struct is_char_type_of_consecutive_lower_alphabet
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
SPROUT_CHAR_LITERAL('a', CharType) + 1 == SPROUT_CHAR_LITERAL('b', CharType)
|
||||
&& SPROUT_CHAR_LITERAL('b', CharType) + 1 == SPROUT_CHAR_LITERAL('c', CharType)
|
||||
&& SPROUT_CHAR_LITERAL('c', CharType) + 1 == SPROUT_CHAR_LITERAL('d', CharType)
|
||||
|
@ -88,8 +86,7 @@ namespace sprout {
|
|||
|
||||
template<typename CharType>
|
||||
struct is_char_type_of_consecutive_upper_alphabet
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
SPROUT_CHAR_LITERAL('A', CharType) + 1 == SPROUT_CHAR_LITERAL('B', CharType)
|
||||
&& SPROUT_CHAR_LITERAL('B', CharType) + 1 == SPROUT_CHAR_LITERAL('C', CharType)
|
||||
&& SPROUT_CHAR_LITERAL('C', CharType) + 1 == SPROUT_CHAR_LITERAL('D', CharType)
|
||||
|
|
|
@ -202,16 +202,14 @@ namespace sprout {
|
|||
public:
|
||||
template<typename T>
|
||||
struct apply
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
(sprout::is_variadic_placeholder<T>::value > 0)
|
||||
>
|
||||
{};
|
||||
};
|
||||
template<typename Bounds, typename = void>
|
||||
struct is_variadic_bounds
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::types::contains_if<Bounds, sprout::detail::is_variadic_placeholder_pred>::value
|
||||
>
|
||||
{};
|
||||
|
@ -297,8 +295,7 @@ namespace sprout {
|
|||
|
||||
template<sprout::index_t I, typename Bounds, std::size_t ArgSize>
|
||||
struct is_variadic_part
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
(sprout::is_variadic_placeholder<
|
||||
typename sprout::tuples::tuple_element<
|
||||
sprout::detail::bound_position<I, Bounds, ArgSize>::value,
|
||||
|
|
|
@ -21,16 +21,14 @@ namespace sprout {
|
|||
namespace hash_detail {
|
||||
template<typename T>
|
||||
struct is_basic_number
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) <= sizeof(std::size_t))
|
||||
>
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_long_number
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& std::is_signed<T>::value
|
||||
|
@ -38,8 +36,7 @@ namespace sprout {
|
|||
{};
|
||||
template<typename T>
|
||||
struct is_ulong_number
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& std::is_unsigned<T>::value
|
||||
|
|
|
@ -19,16 +19,14 @@ namespace sprout {
|
|||
//
|
||||
template<typename Fn>
|
||||
struct is_strict_unary_function
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::has_result_type<Fn>::value
|
||||
&& sprout::has_argument_type<Fn>::value
|
||||
>
|
||||
{};
|
||||
template<typename Fn>
|
||||
struct is_strict_binary_function
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::has_result_type<Fn>::value
|
||||
&& sprout::has_first_argument_type<Fn>::value
|
||||
&& sprout::has_second_argument_type<Fn>::value
|
||||
|
@ -39,8 +37,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Fn>
|
||||
struct is_strict_function
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::is_strict_unary_function<Fn>::value
|
||||
|| sprout::is_strict_binary_function<Fn>::value
|
||||
>
|
||||
|
|
|
@ -50,8 +50,7 @@ namespace sprout {
|
|||
|
||||
template<typename Category1, typename Category2>
|
||||
struct iterator_category_less
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
(sprout::detail::iterator_category_hierarchy<Category1>::value < sprout::detail::iterator_category_hierarchy<Category2>::value)
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -19,8 +19,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename MaybeIterator>
|
||||
struct is_constant_distance_iterator
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
#ifdef SPROUT_NO_CXX14_CONSTEXPR
|
||||
sprout::is_random_access_iterator<MaybeIterator>::value && !std::is_pointer<MaybeIterator>::value
|
||||
#else // #ifdef SPROUT_NO_CXX14_CONSTEXPR
|
||||
|
|
|
@ -79,8 +79,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename MaybeIterator>
|
||||
struct is_iterator_outputable
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::is_output_iterator<typename std::decay<MaybeIterator>::type>::value
|
||||
|| sprout::is_forward_iterator<typename std::decay<MaybeIterator>::type>::value
|
||||
>
|
||||
|
|
|
@ -64,8 +64,7 @@ namespace sprout {
|
|||
|
||||
template<typename T>
|
||||
struct has_address_op
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::detail::has_mem_address_op<T>::value || sprout::detail::has_nonmem_address_op<T>::value
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -27,8 +27,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct is_real_std_random_parameter
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_same<T, float>::value
|
||||
|| std::is_same<T, double>::value
|
||||
|| std::is_same<T, long double>::value
|
||||
|
@ -36,8 +35,7 @@ namespace sprout {
|
|||
{};
|
||||
template<typename T>
|
||||
struct is_int_std_random_parameter
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_same<T, short>::value
|
||||
|| std::is_same<T, int>::value
|
||||
|| std::is_same<T, long>::value
|
||||
|
@ -50,8 +48,7 @@ namespace sprout {
|
|||
{};
|
||||
template<typename T>
|
||||
struct is_uint_std_random_parameter
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_same<T, unsigned short>::value
|
||||
|| std::is_same<T, unsigned int>::value
|
||||
|| std::is_same<T, unsigned long>::value
|
||||
|
|
|
@ -23,8 +23,7 @@ namespace sprout {
|
|||
{};
|
||||
template<typename Tup, std::size_t First, std::size_t Last>
|
||||
struct all_of_impl<Tup, First, Last, false>
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::tpp::detail::all_of_impl<Tup, First, (First + Last) / 2>::value
|
||||
&& sprout::tpp::detail::all_of_impl<Tup, (First + Last) / 2, Last>::value
|
||||
>
|
||||
|
@ -46,7 +45,7 @@ namespace sprout {
|
|||
//
|
||||
template<bool... Values>
|
||||
struct all_of_c
|
||||
: public sprout::tpp::all_of<sprout::integral_constant<bool, Values>...>
|
||||
: public sprout::tpp::all_of<sprout::bool_constant<Values>...>
|
||||
{};
|
||||
} // namespace tpp
|
||||
} // namespace sprout
|
||||
|
|
|
@ -23,8 +23,7 @@ namespace sprout {
|
|||
{};
|
||||
template<typename Tup, std::size_t First, std::size_t Last>
|
||||
struct any_of_impl<Tup, First, Last, false>
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::tpp::detail::any_of_impl<Tup, First, (First + Last) / 2>::value
|
||||
|| sprout::tpp::detail::any_of_impl<Tup, (First + Last) / 2, Last>::value
|
||||
>
|
||||
|
@ -46,7 +45,7 @@ namespace sprout {
|
|||
//
|
||||
template<bool... Values>
|
||||
struct any_of_c
|
||||
: public sprout::tpp::any_of<sprout::integral_constant<bool, Values>...>
|
||||
: public sprout::tpp::any_of<sprout::bool_constant<Values>...>
|
||||
{};
|
||||
} // namespace tpp
|
||||
} // namespace sprout
|
||||
|
|
|
@ -19,12 +19,11 @@ namespace sprout {
|
|||
namespace detail {
|
||||
template<typename Tup, std::size_t First, std::size_t Last, bool = (Last - First == 1)>
|
||||
struct none_of_impl
|
||||
: public sprout::integral_constant<bool, !std::tuple_element<First, Tup>::type::value>
|
||||
: public sprout::bool_constant<!std::tuple_element<First, Tup>::type::value>
|
||||
{};
|
||||
template<typename Tup, std::size_t First, std::size_t Last>
|
||||
struct none_of_impl<Tup, First, Last, false>
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::tpp::detail::none_of_impl<Tup, First, (First + Last) / 2>::value
|
||||
&& sprout::tpp::detail::none_of_impl<Tup, (First + Last) / 2, Last>::value
|
||||
>
|
||||
|
@ -46,7 +45,7 @@ namespace sprout {
|
|||
//
|
||||
template<bool... Values>
|
||||
struct none_of_c
|
||||
: public sprout::tpp::none_of<sprout::integral_constant<bool, Values>...>
|
||||
: public sprout::tpp::none_of<sprout::bool_constant<Values>...>
|
||||
{};
|
||||
} // namespace tpp
|
||||
} // namespace sprout
|
||||
|
|
|
@ -19,12 +19,11 @@ namespace sprout {
|
|||
namespace detail {
|
||||
template<typename Tup, std::size_t First, std::size_t Last, bool = (Last - First == 1)>
|
||||
struct one_of_impl_1
|
||||
: public sprout::integral_constant<bool, !std::tuple_element<First, Tup>::type::value>
|
||||
: public sprout::bool_constant<!std::tuple_element<First, Tup>::type::value>
|
||||
{};
|
||||
template<typename Tup, std::size_t First, std::size_t Last>
|
||||
struct one_of_impl_1<Tup, First, Last, false>
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::tpp::detail::one_of_impl_1<Tup, First, (First + Last) / 2>::value
|
||||
&& sprout::tpp::detail::one_of_impl_1<Tup, (First + Last) / 2, Last>::value
|
||||
>
|
||||
|
@ -36,8 +35,7 @@ namespace sprout {
|
|||
{};
|
||||
template<typename Tup, std::size_t First, std::size_t Last>
|
||||
struct one_of_impl<Tup, First, Last, false>
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::tpp::detail::one_of_impl<Tup, First, (First + Last) / 2>::value
|
||||
? sprout::tpp::detail::one_of_impl_1<Tup, (First + Last) / 2, Last>::value
|
||||
: sprout::tpp::detail::one_of_impl<Tup, (First + Last) / 2, Last>::value
|
||||
|
@ -60,7 +58,7 @@ namespace sprout {
|
|||
//
|
||||
template<bool... Values>
|
||||
struct one_of_c
|
||||
: public sprout::tpp::one_of<sprout::integral_constant<bool, Values>...>
|
||||
: public sprout::tpp::one_of<sprout::bool_constant<Values>...>
|
||||
{};
|
||||
// namespace detail {
|
||||
// template<bool... Values>
|
||||
|
@ -83,7 +81,7 @@ namespace sprout {
|
|||
// {};
|
||||
// template<bool... Tail>
|
||||
// struct one_of_impl<false, Tail...>
|
||||
// : public sprout::integral_constant<bool, sprout::tpp::detail::one_of_impl<Tail...>::value>
|
||||
// : public sprout::bool_constant<sprout::tpp::detail::one_of_impl<Tail...>::value>
|
||||
// {};
|
||||
// } // namespace detail
|
||||
// //
|
||||
|
|
|
@ -238,8 +238,7 @@ namespace sprout {
|
|||
|
||||
template<typename... UTypes>
|
||||
struct is_fixedly_convert_constructible
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
(sizeof...(UTypes) == sizeof...(Types) && is_flexibly_convert_constructible<UTypes...>::value)
|
||||
>
|
||||
{};
|
||||
|
@ -270,8 +269,7 @@ namespace sprout {
|
|||
|
||||
template<typename... UTypes>
|
||||
struct is_fixedly_assignable
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
(sizeof...(UTypes) == sizeof...(Types) && is_flexibly_assignable<UTypes...>::value)
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace sprout {
|
|||
{};
|
||||
template<std::size_t I, typename T>
|
||||
struct valid_tuple_index<I, T, true>
|
||||
: public sprout::integral_constant<bool, (I < std::tuple_size<T>::value)>
|
||||
: public sprout::bool_constant<(I < std::tuple_size<T>::value)>
|
||||
{};
|
||||
|
||||
template<std::size_t I, typename T, bool = sprout::has_type<std::tuple_element<I, T> >::value && sprout::tuples::detail::valid_tuple_index<I, T>::value>
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace sprout { \
|
|||
namespace types { \
|
||||
template<typename T, typename U> \
|
||||
struct NAME \
|
||||
: public sprout::integral_constant<bool, ((T::value) OP (U::value))> \
|
||||
: public sprout::bool_constant<((T::value) OP (U::value))> \
|
||||
{}; \
|
||||
typedef sprout::types::quote<sprout::types::NAME> SPROUT_PP_CAT(NAME, _); \
|
||||
SPROUT_TYPES_DETAIL_FUNCTIONAL_COMPARISON_OP_VT_DECL(NAME) \
|
||||
|
|
|
@ -19,8 +19,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Tuple>
|
||||
struct empty
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
(sprout::types::tuple_size<Tuple>::value == 0)
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -36,12 +36,26 @@ namespace sprout {
|
|||
return std::integral_constant<T, V>::value;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// bool_constant
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<bool V>
|
||||
using bool_constant = sprout::integral_constant<bool, V>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<bool V>
|
||||
struct bool_constant
|
||||
: public sprout::integral_constant<bool, V>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
//
|
||||
// true_type
|
||||
// false_type
|
||||
//
|
||||
typedef sprout::integral_constant<bool, true> true_type;
|
||||
typedef sprout::integral_constant<bool, false> false_type;
|
||||
typedef sprout::bool_constant<true> true_type;
|
||||
typedef sprout::bool_constant<false> false_type;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP
|
||||
|
|
|
@ -18,8 +18,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct is_const_unqualified
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_const<T>::value
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -19,8 +19,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct is_cv_unqualified
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::is_const_unqualified<T>::value && sprout::is_volatile_unqualified<T>::value
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -19,8 +19,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename From, typename To>
|
||||
struct is_nullptr_cast
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::is_pointer<To>::value && sprout::is_same<typename sprout::decay<From>::type, std::nullptr_t>::value
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -18,8 +18,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct is_sint
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value && std::is_signed<T>::value
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -18,8 +18,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct is_uint
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_integral<T>::value && std::is_unsigned<T>::value
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -19,8 +19,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename From, typename To>
|
||||
struct is_upcast
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
sprout::is_nullptr_cast<From, To>::value
|
||||
|| (sprout::is_pointer<To>::value
|
||||
&& sprout::is_base_of<typename sprout::remove_pointer<To>::type, typename sprout::remove_pointer<typename sprout::decay<From>::type>::type>::value
|
||||
|
|
|
@ -18,8 +18,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct is_volatile_unqualified
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_volatile<T>::value
|
||||
>
|
||||
{};
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace sprout {
|
|||
#if SPROUT_CLANG_HAS_FUTURE(is_trivially_constructible)
|
||||
template<typename T, typename... Args>
|
||||
struct is_trivially_constructible
|
||||
: public sprout::integral_constant<bool, __is_trivially_constructible(T, Args...)>
|
||||
: public sprout::bool_constant<__is_trivially_constructible(T, Args...)>
|
||||
{};
|
||||
#else // #if SPROUT_CLANG_HAS_FUTURE(is_trivially_constructible)
|
||||
template<typename T, typename... Args>
|
||||
|
@ -214,7 +214,7 @@ namespace sprout {
|
|||
#if SPROUT_CLANG_HAS_FUTURE(has_trivial_constructor) || SPROUT_GCC_OR_LATER(4, 3, 0)
|
||||
template<typename T>
|
||||
struct is_trivially_constructible<T>
|
||||
: public sprout::integral_constant<bool, __has_trivial_constructor(T)>
|
||||
: public sprout::bool_constant<__has_trivial_constructor(T)>
|
||||
{};
|
||||
#else // #if SPROUT_CLANG_HAS_FUTURE(has_trivial_constructor) || SPROUT_GCC_OR_LATER(4, 3, 0)
|
||||
template<typename T>
|
||||
|
@ -254,7 +254,7 @@ namespace sprout {
|
|||
#if SPROUT_CLANG_HAS_FUTURE(is_trivially_assignable)
|
||||
template<typename T, typename U>
|
||||
struct is_trivially_assignable
|
||||
: public sprout::integral_constant<bool, __is_trivially_assignable(T, U)>
|
||||
: public sprout::bool_constant<__is_trivially_assignable(T, U)>
|
||||
{};
|
||||
#else // #if SPROUT_CLANG_HAS_FUTURE(is_trivially_assignable)
|
||||
template<typename T, typename U>
|
||||
|
@ -330,13 +330,12 @@ namespace sprout {
|
|||
#if SPROUT_CLANG_HAS_FUTURE(has_trivial_destructor) || SPROUT_GCC_OR_LATER(4, 3, 0)
|
||||
template<typename T>
|
||||
struct is_trivially_destructible
|
||||
: public sprout::integral_constant<bool, __has_trivial_destructor(T)>
|
||||
: public sprout::bool_constant<__has_trivial_destructor(T)>
|
||||
{};
|
||||
#else // #if SPROUT_CLANG_HAS_FUTURE(has_trivial_destructor) || SPROUT_GCC_OR_LATER(4, 3, 0)
|
||||
template<typename T>
|
||||
struct is_trivially_destructible
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_scalar<typename std::remove_all_extents<T>::type>::value
|
||||
|| std::is_reference<typename std::remove_all_extents<T>::type>::value
|
||||
>
|
||||
|
@ -379,8 +378,7 @@ namespace sprout {
|
|||
#if !defined(_LIBCPP_VERSION) && SPROUT_GCC_EARLIER(4, 8, 0)
|
||||
template<typename T>
|
||||
struct is_nothrow_destructible
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_scalar<typename std::remove_all_extents<T>::type>::value
|
||||
|| std::is_reference<typename std::remove_all_extents<T>::type>::value
|
||||
>
|
||||
|
|
|
@ -18,8 +18,7 @@ namespace sprout {
|
|||
namespace detail {
|
||||
template<typename From, typename To>
|
||||
struct is_same_reinterpret_cast
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
(sprout::is_reference<To>::value
|
||||
&& sprout::is_same<typename sprout::decay<From>::type, typename sprout::decay<To>::type>::value
|
||||
&& sprout::is_convertible<From, To>::value
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/string/char_traits.hpp>
|
||||
#include <sprout/utility/string_ref/string_ref.hpp>
|
||||
#include <sprout/utility/string_ref/type_traits.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -41,6 +42,125 @@ namespace sprout {
|
|||
template<typename T, typename Traits = sprout::char_traits<T> >
|
||||
using basic_string_view = sprout::basic_string_ref<T, Traits>;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
//
|
||||
// to_string_view
|
||||
//
|
||||
template<typename T, typename Traits>
|
||||
inline SPROUT_CONSTEXPR sprout::basic_string_ref<T, Traits>
|
||||
to_string_view(sprout::basic_string_ref<T, Traits> const& s) {
|
||||
return sprout::to_string_ref(s);
|
||||
}
|
||||
template<typename T, std::size_t N, typename Traits>
|
||||
inline SPROUT_CONSTEXPR sprout::basic_string_ref<T, Traits>
|
||||
to_string_view(sprout::basic_string<T, N, Traits> const& s) {
|
||||
return sprout::to_string_ref(s);
|
||||
}
|
||||
template<typename T, typename Traits>
|
||||
inline SPROUT_NON_CONSTEXPR sprout::basic_string_ref<T, Traits>
|
||||
to_string_view(std::basic_string<T, Traits> const& s) {
|
||||
return sprout::to_string_ref(s);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::basic_string_ref<T>
|
||||
to_string_view(T const* str) {
|
||||
return sprout::to_string_ref(str);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::basic_string_ref<T>
|
||||
to_string_view(T const* str, std::size_t len) {
|
||||
return sprout::to_string_ref(str, len);
|
||||
}
|
||||
|
||||
//
|
||||
// is_basic_string_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_basic_string_view = sprout::is_basic_string_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
struct is_basic_string_view
|
||||
: public sprout::is_basic_string_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
//
|
||||
// is_string_view_of
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
using is_string_view_of = sprout::is_string_ref_of<T, Elem>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_string_view_of
|
||||
: public sprout::is_string_ref_of<T, Elem>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
//
|
||||
// is_string_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_string_view = sprout::is_string_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_string_view
|
||||
: public sprout::is_string_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
//
|
||||
// is_wstring_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_wstring_view = sprout::is_wstring_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_wstring_view
|
||||
: public sprout::is_wstring_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
//
|
||||
// is_u16string_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_u16string_view = sprout::is_u16string_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_u16string_view
|
||||
: public sprout::is_u16string_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
//
|
||||
// is_u32string_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_u32string_view = sprout::is_u32string_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_u32string_view
|
||||
: public sprout::is_u32string_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
#if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_basic_string_view_v = sprout::is_basic_string_view<T>::value;
|
||||
template<typename T, typename Elem>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_string_view_of_v = sprout::is_string_view_of<T, Elem>::value;
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_string_view_v = sprout::is_string_view<T>::value;
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_wstring_view_v = sprout::is_wstring_view<T>::value;
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_u16string_view_v = sprout::is_u16string_view<T>::value;
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_u32string_view_v = sprout::is_u32string_view<T>::value;
|
||||
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_UTILITY_STRING_REF_ALIAS_HPP
|
||||
|
|
|
@ -54,8 +54,7 @@ namespace sprout {
|
|||
private:
|
||||
template<typename Iterator>
|
||||
class is_string_ref_iterator
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_same<Iterator, sprout::index_iterator<basic_string_ref&, true> >::value
|
||||
|| std::is_same<Iterator, sprout::index_iterator<basic_string_ref const&, true> >::value
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue