add type_traits for variable templates version

This commit is contained in:
bolero-MURAKAMI 2014-03-15 18:11:11 +09:00
parent 7e709630c6
commit 61dd3351fc
26 changed files with 205 additions and 48 deletions

View file

@ -33,6 +33,11 @@ namespace sprout {
struct is_array_class<sprout::array<T, N> >
: public sprout::true_type
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_array_class_v = sprout::is_array_class<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_ARRAY_TYPE_TRAITS_HPP

View file

@ -22,6 +22,17 @@ namespace sprout {
SPROUT_HAS_XXX_TYPE_DEF_LAZY(argument_type);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(first_argument_type);
SPROUT_HAS_XXX_TYPE_DEF_LAZY(second_argument_type);
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool has_result_type_v = sprout::has_result_type<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool has_argument_type_v = sprout::has_argument_type<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool has_first_argument_type_v = sprout::has_first_argument_type<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool has_second_argument_type_v = sprout::has_second_argument_type<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_HAS_TYPE_HPP

View file

@ -15,6 +15,7 @@
namespace sprout {
//
// is_strict_unary_function
// is_strict_binary_function
//
template<typename Fn>
struct is_strict_unary_function
@ -24,9 +25,6 @@ namespace sprout {
&& sprout::has_argument_type<Fn>::value
>
{};
//
// is_strict_binary_function
//
template<typename Fn>
struct is_strict_binary_function
: public sprout::integral_constant<
@ -36,6 +34,13 @@ namespace sprout {
&& sprout::has_second_argument_type<Fn>::value
>
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_strict_unary_function_v = sprout::is_strict_unary_function<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_strict_binary_function_v = sprout::is_strict_binary_function<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_IS_STRICT_FUNCTION_HPP

View file

@ -16,6 +16,11 @@ namespace sprout {
// is_transparent_function
//
SPROUT_HAS_XXX_TYPE_DEF(is_transparent_function, is_transparent);
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_transparent_function_v = sprout::is_transparent_function<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_IS_TRANSPARENT_FUNCTION_HPP

View file

@ -87,6 +87,11 @@ namespace sprout {
SPROUT_EXPLICIT_EMPTY_BASE_CLASS_CONSTRUCT_BODY
#endif
};
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename T>
using weak_result_type_t = typename sprout::weak_result_type<T>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace sprout
#endif // #ifndef SPROUT_FUNCTIONAL_TYPE_TRAITS_WEAK_RESULT_TYPE_HPP

View file

@ -167,6 +167,21 @@ namespace sprout {
struct common_iterator_difference_type
: public sprout::common_decay<typename std::iterator_traits<Iterators>::difference_type...>
{};
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename Head, typename... Tail>
using min_iterator_category_t = typename sprout::min_iterator_category<Head, Tail...>::type;
template<typename... Iterators>
using common_iterator_category_t = typename sprout::common_iterator_category<Iterators...>::type;
template<typename... Iterators>
using common_iterator_reference_t = typename sprout::common_iterator_reference<Iterators...>::type;
template<typename... Iterators>
using common_iterator_value_type_t = typename sprout::common_iterator_value_type<Iterators...>::type;
template<typename... Iterators>
using common_iterator_pointer_t = typename sprout::common_iterator_pointer<Iterators...>::type;
template<typename... Iterators>
using common_iterator_difference_type_t = typename sprout::common_iterator_difference_type<Iterators...>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_COMMON_HPP

View file

@ -28,6 +28,11 @@ namespace sprout {
#endif // #ifdef SPROUT_NO_CXX14_CONSTEXPR
>
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename MaybeIterator>
SPROUT_STATIC_CONSTEXPR bool is_constant_distance_iterator_v = sprout::is_constant_distance_iterator<MaybeIterator>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_CONSTANT_DISTANCE_ITERATOR_HPP

View file

@ -23,10 +23,15 @@ namespace sprout {
//
// is_iterator
//
template<typename MaybeIterator>
template<typename T>
struct is_iterator
: public sprout::detail::has_iterator_category<std::iterator_traits<MaybeIterator> >
: public sprout::detail::has_iterator_category<std::iterator_traits<T> >
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_iterator_v = sprout::is_iterator<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_HPP

View file

@ -56,6 +56,21 @@ namespace sprout {
struct is_random_access_iterator_category
: public sprout::is_iterator_category_of<MaybeCategory, std::random_access_iterator_tag>
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename MaybeCategory, typename Category>
SPROUT_STATIC_CONSTEXPR bool is_iterator_category_of_v = sprout::is_iterator_category_of<MaybeCategory, Category>::value;
template<typename MaybeCategory>
SPROUT_STATIC_CONSTEXPR bool is_input_iterator_category_v = sprout::is_input_iterator_category<MaybeCategory>::value;
template<typename MaybeCategory>
SPROUT_STATIC_CONSTEXPR bool is_output_iterator_category_v = sprout::is_output_iterator_category<MaybeCategory>::value;
template<typename MaybeCategory>
SPROUT_STATIC_CONSTEXPR bool is_forward_iterator_category_v = sprout::is_forward_iterator_category<MaybeCategory>::value;
template<typename MaybeCategory>
SPROUT_STATIC_CONSTEXPR bool is_bidirectional_iterator_category_v = sprout::is_bidirectional_iterator_category<MaybeCategory>::value;
template<typename MaybeCategory>
SPROUT_STATIC_CONSTEXPR bool is_random_access_iterator_category_v = sprout::is_random_access_iterator_category<MaybeCategory>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_CATEGORY_OF_HPP

View file

@ -85,6 +85,23 @@ namespace sprout {
|| sprout::is_forward_iterator<typename std::decay<MaybeIterator>::type>::value
>
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename MaybeIterator, typename Category>
SPROUT_STATIC_CONSTEXPR bool is_iterator_of_v = sprout::is_iterator_of<MaybeIterator, Category>::value;
template<typename MaybeIterator>
SPROUT_STATIC_CONSTEXPR bool is_input_iterator_v = sprout::is_input_iterator<MaybeIterator>::value;
template<typename MaybeIterator>
SPROUT_STATIC_CONSTEXPR bool is_output_iterator_v = sprout::is_output_iterator<MaybeIterator>::value;
template<typename MaybeIterator>
SPROUT_STATIC_CONSTEXPR bool is_forward_iterator_v = sprout::is_forward_iterator<MaybeIterator>::value;
template<typename MaybeIterator>
SPROUT_STATIC_CONSTEXPR bool is_bidirectional_iterator_v = sprout::is_bidirectional_iterator<MaybeIterator>::value;
template<typename MaybeIterator>
SPROUT_STATIC_CONSTEXPR bool is_random_access_iterator_v = sprout::is_random_access_iterator<MaybeIterator>::value;
template<typename MaybeIterator>
SPROUT_STATIC_CONSTEXPR bool is_iterator_outputable_v = sprout::is_iterator_outputable<MaybeIterator>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_OF_HPP

View file

@ -32,6 +32,11 @@ namespace sprout {
struct is_pit<sprout::pit<Container> >
: public sprout::true_type
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_pit_v = sprout::is_pit<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_PIT_TYPE_TRAITS_HPP

View file

@ -25,39 +25,50 @@ namespace sprout {
// is_int_std_random_parameter
// is_uint_std_random_parameter
//
template<typename RealType>
template<typename T>
struct is_real_std_random_parameter
: public sprout::integral_constant<
bool,
std::is_same<RealType, float>::value
|| std::is_same<RealType, double>::value
|| std::is_same<RealType, long double>::value
std::is_same<T, float>::value
|| std::is_same<T, double>::value
|| std::is_same<T, long double>::value
>
{};
template<typename IntType>
template<typename T>
struct is_int_std_random_parameter
: public sprout::integral_constant<
bool,
std::is_same<IntType, short>::value
|| std::is_same<IntType, int>::value
|| std::is_same<IntType, long>::value
|| std::is_same<IntType, long long>::value
|| std::is_same<IntType, unsigned short>::value
|| std::is_same<IntType, unsigned int>::value
|| std::is_same<IntType, unsigned long>::value
|| std::is_same<IntType, unsigned long long>::value
std::is_same<T, short>::value
|| std::is_same<T, int>::value
|| std::is_same<T, long>::value
|| std::is_same<T, long long>::value
|| std::is_same<T, unsigned short>::value
|| std::is_same<T, unsigned int>::value
|| std::is_same<T, unsigned long>::value
|| std::is_same<T, unsigned long long>::value
>
{};
template<typename UIntType>
template<typename T>
struct is_uint_std_random_parameter
: public sprout::integral_constant<
bool,
std::is_same<UIntType, unsigned short>::value
|| std::is_same<UIntType, unsigned int>::value
|| std::is_same<UIntType, unsigned long>::value
|| std::is_same<UIntType, unsigned long long>::value
std::is_same<T, unsigned short>::value
|| std::is_same<T, unsigned int>::value
|| std::is_same<T, unsigned long>::value
|| std::is_same<T, unsigned long long>::value
>
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_seed_seq_v = sprout::random::is_seed_seq<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_real_std_random_parameter_v = sprout::random::is_real_std_random_parameter<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_int_std_random_parameter_v = sprout::random::is_int_std_random_parameter<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_uint_std_random_parameter_v = sprout::random::is_uint_std_random_parameter<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace random
} // namespace sprout

View file

@ -25,6 +25,11 @@ namespace sprout {
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>::iterator type;
};
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename Range>
using lvalue_iterator_t = typename sprout::range::lvalue_iterator<Range>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace range
} // namespace sprout

View file

@ -22,6 +22,11 @@ namespace sprout {
public:
typedef sprout::range::range_container<typename sprout::range::lvalue_iterator<Range>::type> type;
};
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename Range>
using lvalue_range_t = typename sprout::range::lvalue_range<Range>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace range
} // namespace sprout

View file

@ -115,6 +115,21 @@ namespace sprout {
struct is_u32string
: public sprout::is_string_of<T, char32_t>
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_basic_string_v = sprout::is_basic_string<T>::value;
template<typename T, typename Elem>
SPROUT_STATIC_CONSTEXPR bool is_string_of_v = sprout::is_string_of<T, Elem>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_string_v = sprout::is_string<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_wstring_v = sprout::is_wstring<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_u16string_v = sprout::is_u16string<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_u32string_v = sprout::is_u32string<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_STRING_TYPE_TRAITS_HPP

View file

@ -32,6 +32,11 @@ namespace sprout {
struct is_sub_array<sprout::sub_array<Container> >
: public sprout::true_type
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_sub_array_v = sprout::is_sub_array<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_SUB_ARRAY_TYPE_TRAITS_HPP

View file

@ -43,6 +43,15 @@ namespace sprout {
} // namespace tuples
using sprout::tuples::tuple_element;
#if SPROUT_USE_TEMPLATE_ALIASES
namespace tuples {
template<std::size_t I, typename T>
using tuple_element_t = typename sprout::tuples::tuple_element<I, T>::type;
} // namespace tuples
using sprout::tuples::tuple_element_t;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace sprout
#endif // #ifndef SPROUT_TUPLE_TUPLE_TUPLE_ELEMENT_HPP

View file

@ -8,6 +8,7 @@
#ifndef SPROUT_TUPLE_TUPLE_TUPLE_SIZE_HPP
#define SPROUT_TUPLE_TUPLE_TUPLE_SIZE_HPP
#include <cstddef>
#include <tuple>
#include <sprout/config.hpp>
#include <sprout/type_traits/detail/type_traits_wrapper.hpp>
@ -36,6 +37,15 @@ namespace sprout {
} // namespace tuples
using sprout::tuples::tuple_size;
#if SPROUT_USE_VARIABLE_TEMPLATES
namespace tuples {
template<typename T>
SPROUT_STATIC_CONSTEXPR std::size_t tuple_size_v = sprout::tuples::tuple_size<T>::value;
} // namespace tuples
using sprout::tuples::tuple_size_v;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_TUPLE_TUPLE_TUPLE_SIZE_HPP

View file

@ -36,6 +36,15 @@ namespace sprout {
} // namespace tuples
using sprout::tuples::is_tuple;
#if SPROUT_USE_VARIABLE_TEMPLATES
namespace tuples {
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_tuple_v = sprout::tuples::is_tuple_v<T>::value;
} // namespace tuples
using sprout::tuples::is_tuple;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_TUPLE_TUPLE_TYPE_TRAITS_HPP

View file

@ -48,11 +48,6 @@ namespace sprout {
struct is_c_str<char32_t[N]>
: public sprout::true_type
{};
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename T>
using is_c_str_t = typename sprout::is_c_str<T>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_C_STR_HPP

View file

@ -47,11 +47,6 @@ namespace sprout {
struct is_char_type<char32_t>
: public sprout::true_type
{};
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename T>
using is_char_type_t = typename sprout::is_char_type<T>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_CHAR_TYPE_HPP

View file

@ -30,11 +30,6 @@ namespace sprout {
struct is_convert_constructible
: public sprout::identity<decltype(sprout::detail::is_convert_constructible_test<T>::test(std::declval<Arg>()))>::type
{};
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename T, typename Arg>
using is_convert_constructible_t = typename sprout::is_convert_constructible<T, Arg>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_CONVERT_CONSTRUCTIBLE_HPP

View file

@ -23,11 +23,6 @@ namespace sprout {
std::is_integral<T>::value && std::is_signed<T>::value
>
{};
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename T>
using is_sint_t = typename sprout::is_sint<T>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_SINT_HPP

View file

@ -23,11 +23,6 @@ namespace sprout {
std::is_integral<T>::value && std::is_unsigned<T>::value
>
{};
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename T>
using is_uint_t = typename sprout::is_uint<T>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_UINT_HPP

View file

@ -81,6 +81,21 @@ namespace sprout {
struct is_u32string_ref
: public sprout::is_string_ref_of<T, char32_t>
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_basic_string_ref_v = sprout::is_basic_string_ref<T>::value;
template<typename T, typename Elem>
SPROUT_STATIC_CONSTEXPR bool is_string_ref_of_v = sprout::is_string_ref_of<T, Elem>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_string_ref_v = sprout::is_string_ref<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_wstring_ref_v = sprout::is_wstring_ref<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_u16string_ref_v = sprout::is_u16string_ref<T>::value;
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_u32string_ref_v = sprout::is_u32string_ref<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_UTILITY_STRING_REF_TYPE_TRAITS_HPP

View file

@ -32,6 +32,11 @@ namespace sprout {
struct is_variant<sprout::variant<Types...> >
: public sprout::true_type
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_variant_v = sprout::is_variant<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_VARIANT_TYPE_TRAITS_HPP