rename type_traits is_int -> is_sint

add new type_traits is_*_unqualified
This commit is contained in:
bolero-MURAKAMI 2014-03-15 12:06:51 +09:00
parent 86db277625
commit 7e709630c6
12 changed files with 172 additions and 42 deletions

View file

@ -14,7 +14,7 @@
#include <sprout/limits.hpp>
#include <sprout/algorithm/clamp.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/type_traits/is_int.hpp>
#include <sprout/type_traits/is_sint.hpp>
#include <sprout/type_traits/is_uint.hpp>
#include <sprout/range/adaptor/transformed.hpp>
@ -26,7 +26,7 @@ namespace sprout {
template<typename IntType>
struct normalized_to_pcm_wave<
IntType,
typename std::enable_if<sprout::is_int<IntType>::value>::type
typename std::enable_if<sprout::is_sint<IntType>::value>::type
> {
public:
typedef IntType result_type;

View file

@ -11,7 +11,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/type_traits/is_int.hpp>
#include <sprout/type_traits/is_sint.hpp>
#include <sprout/type_traits/is_uint.hpp>
namespace sprout {
@ -56,7 +56,7 @@ namespace sprout {
//
template<
int Base = 10, typename IntType,
typename sprout::enabler_if<sprout::is_int<IntType>::value>::type = sprout::enabler
typename sprout::enabler_if<sprout::is_sint<IntType>::value>::type = sprout::enabler
>
inline SPROUT_CONSTEXPR int
int_digit_at(IntType val, int digits) {

View file

@ -10,7 +10,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/is_int.hpp>
#include <sprout/type_traits/is_sint.hpp>
#include <sprout/type_traits/is_uint.hpp>
#include <sprout/type_traits/enabler_if.hpp>
@ -48,7 +48,7 @@ namespace sprout {
}
template<
typename T, typename IntType,
typename sprout::enabler_if<sprout::is_int<IntType>::value>::type = sprout::enabler
typename sprout::enabler_if<sprout::is_sint<IntType>::value>::type = sprout::enabler
>
inline SPROUT_CONSTEXPR T
pow_n(T const& x, IntType n) {

View file

@ -29,6 +29,7 @@
#include <sprout/functional/type_traits/weak_result_type.hpp>
#include <sprout/functional/bind/placeholder.hpp>
#include <sprout/type_traits/integral_constant.hpp>
#include <sprout/type_traits/identity.hpp>
namespace sprout {
// 20.8.9 bind
@ -514,9 +515,9 @@ namespace sprout {
binder(binder const&) = default;
template<
typename... Args,
typename Result = decltype(
typename Result = typename sprout::identity<decltype(
impl_type::template call_(std::declval<sprout::tuples::tuple<Args...> >(), sprout::detail::bound_indexes<bounds_type, sizeof...(Args)>::make())
)
)>::type
>
Result operator()(Args&&... args) {
return impl_type::template call<Result>(
@ -526,9 +527,9 @@ namespace sprout {
}
template<
typename... Args,
typename Result = decltype(
typename Result = typename sprout::identity<decltype(
impl_type::template call_c_(std::declval<sprout::tuples::tuple<Args...> >(), sprout::detail::bound_indexes<bounds_type, sizeof...(Args)>::make())
)
)>::type
>
SPROUT_CONSTEXPR Result operator()(Args&&... args) const {
return impl_type::template call_c<Result>(
@ -538,9 +539,9 @@ namespace sprout {
}
template<
typename... Args,
typename Result = decltype(
typename Result = typename sprout::identity<decltype(
impl_type::template call_v_(std::declval<sprout::tuples::tuple<Args...> >(), sprout::detail::bound_indexes<bounds_type, sizeof...(Args)>::make())
)
)>::type
>
Result operator()(Args&&... args) volatile {
return impl_type::template call_v<Result>(
@ -550,9 +551,9 @@ namespace sprout {
}
template<
typename... Args,
typename Result = decltype(
typename Result = typename sprout::identity<decltype(
impl_type::template call_cv_(std::declval<sprout::tuples::tuple<Args...> >(), sprout::detail::bound_indexes<bounds_type, sizeof...(Args)>::make())
)
)>::type
>
SPROUT_CONSTEXPR Result operator()(Args&&... args) const volatile {
return impl_type::template call_cv<Result>(
@ -581,9 +582,9 @@ namespace sprout {
cbinder(cbinder const&) = default;
template<
typename... Args,
typename Result = decltype(
typename Result = typename sprout::identity<decltype(
impl_type::template call_c_(std::declval<sprout::tuples::tuple<Args...> >(), sprout::detail::bound_indexes<bounds_type, sizeof...(Args)>::make())
)
)>::type
>
SPROUT_CONSTEXPR Result operator()(Args&&... args) const {
return impl_type::template call_c<Result>(
@ -593,9 +594,9 @@ namespace sprout {
}
template<
typename... Args,
typename Result = decltype(
typename Result = typename sprout::identity<decltype(
impl_type::template call_cv_(std::declval<sprout::tuples::tuple<Args...> >(), sprout::detail::bound_indexes<bounds_type, sizeof...(Args)>::make())
)
)>::type
>
SPROUT_CONSTEXPR Result operator()(Args&&... args) const volatile {
return impl_type::template call_cv<Result>(

View file

@ -23,13 +23,13 @@ namespace sprout {
public:
template<
typename U = T,
typename = decltype(std::declval<U>().generated_value())
typename = typename sprout::identity<decltype(std::declval<U>().generated_value())>::type
>
static sprout::true_type test(int);
static sprout::false_type test(...);
};
#if defined(_MSC_VER)
template<typename T, typename Base_ = decltype(sprout::generators::detail::has_mem_generated_value_test<T>::test(0))>
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout::generators::detail::has_mem_generated_value_test<T>::test(0))>::type>
struct has_mem_generated_value
: public Base_
{};
@ -98,13 +98,13 @@ namespace sprout {
public:
template<
typename U = T,
typename = decltype(std::declval<U>().next_generator())
typename = typename sprout::identity<decltype(std::declval<U>().next_generator())>::type
>
static sprout::true_type test(int);
static sprout::false_type test(...);
};
#if defined(_MSC_VER)
template<typename T, typename Base_ = decltype(sprout::generators::detail::has_mem_next_generator_test<T>::test(0))>
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout::generators::detail::has_mem_next_generator_test<T>::test(0))>::type>
struct has_mem_next_generator
: public Base_
{};

View file

@ -13,7 +13,7 @@
#include <sprout/config.hpp>
#include <sprout/cstdint.hpp>
#include <sprout/array/array.hpp>
#include <sprout/type_traits/is_int.hpp>
#include <sprout/type_traits/is_sint.hpp>
#include <sprout/type_traits/is_uint.hpp>
#include <sprout/assert.hpp>
@ -530,7 +530,7 @@ namespace sprout {
struct factorials;
template<typename T>
struct factorials<T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 1>::type> {
struct factorials<T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 1>::type> {
public:
typedef T type;
public:
@ -544,9 +544,9 @@ namespace sprout {
};
template<typename T>
SPROUT_CONSTEXPR_OR_CONST typename sprout::math::detail::factorials<
T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 1>::type
T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 1>::type
>::table_type sprout::math::detail::factorials<
T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 1>::type
T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 1>::type
>::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_INT_1);
template<typename T>
@ -570,7 +570,7 @@ namespace sprout {
>::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_UINT_1);
template<typename T>
struct factorials<T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 2>::type> {
struct factorials<T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 2>::type> {
public:
typedef T type;
public:
@ -584,9 +584,9 @@ namespace sprout {
};
template<typename T>
SPROUT_CONSTEXPR_OR_CONST typename sprout::math::detail::factorials<
T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 2>::type
T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 2>::type
>::table_type sprout::math::detail::factorials<
T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 2>::type
T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 2>::type
>::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_INT_2);
template<typename T>
@ -610,7 +610,7 @@ namespace sprout {
>::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_UINT_2);
template<typename T>
struct factorials<T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 4>::type> {
struct factorials<T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 4>::type> {
public:
typedef T type;
public:
@ -624,9 +624,9 @@ namespace sprout {
};
template<typename T>
SPROUT_CONSTEXPR_OR_CONST typename sprout::math::detail::factorials<
T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 4>::type
T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 4>::type
>::table_type sprout::math::detail::factorials<
T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 4>::type
T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 4>::type
>::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_INT_4);
template<typename T>
@ -650,7 +650,7 @@ namespace sprout {
>::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_UINT_4);
template<typename T>
struct factorials<T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 8>::type> {
struct factorials<T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 8>::type> {
public:
typedef T type;
public:
@ -664,9 +664,9 @@ namespace sprout {
};
template<typename T>
SPROUT_CONSTEXPR_OR_CONST typename sprout::math::detail::factorials<
T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 8>::type
T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 8>::type
>::table_type sprout::math::detail::factorials<
T, typename std::enable_if<sprout::is_int<T>::value && sizeof(T) == 8>::type
T, typename std::enable_if<sprout::is_sint<T>::value && sizeof(T) == 8>::type
>::table SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(SPROUT_FACTORIAL_TABLE_DEF_INT_8);
template<typename T>

View file

@ -8,7 +8,9 @@
#ifndef SPROUT_RANDOM_TYPE_TRAITS_HPP
#define SPROUT_RANDOM_TYPE_TRAITS_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/integral_constant.hpp>
#include <sprout/type_traits/has_xxx.hpp>
namespace sprout {
@ -17,6 +19,45 @@ namespace sprout {
// is_seed_seq
//
SPROUT_HAS_XXX_TYPE_DEF(is_seed_seq, result_type);
//
// is_real_std_random_parameter
// is_int_std_random_parameter
// is_uint_std_random_parameter
//
template<typename RealType>
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
>
{};
template<typename IntType>
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
>
{};
template<typename UIntType>
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
>
{};
} // namespace random
} // namespace sprout

View file

@ -11,7 +11,10 @@
#include <sprout/config.hpp>
#include <sprout/type_traits/std.hpp>
#include <sprout/type_traits/is_convert_constructible.hpp>
#include <sprout/type_traits/is_int.hpp>
#include <sprout/type_traits/is_const_unqualified.hpp>
#include <sprout/type_traits/is_volatile_unqualified.hpp>
#include <sprout/type_traits/is_cv_unqualified.hpp>
#include <sprout/type_traits/is_sint.hpp>
#include <sprout/type_traits/is_uint.hpp>
#include <sprout/type_traits/is_char_type.hpp>
#include <sprout/type_traits/is_c_str.hpp>

View file

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2011-2014 Bolero MURAKAMI
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_TYPE_TRAITS_IS_CONST_UNQUALIFIED_HPP
#define SPROUT_TYPE_TRAITS_IS_CONST_UNQUALIFIED_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/integral_constant.hpp>
namespace sprout {
//
// is_const_unqualified
//
template<typename T>
struct is_const_unqualified
: public sprout::integral_constant<
bool,
std::is_const<T>::value
>
{};
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_CONST_UNQUALIFIED_HPP

View file

@ -0,0 +1,29 @@
/*=============================================================================
Copyright (c) 2011-2014 Bolero MURAKAMI
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_TYPE_TRAITS_IS_CV_UNQUALIFIED_HPP
#define SPROUT_TYPE_TRAITS_IS_CV_UNQUALIFIED_HPP
#include <sprout/config.hpp>
#include <sprout/type_traits/integral_constant.hpp>
#include <sprout/type_traits/is_const_unqualified.hpp>
#include <sprout/type_traits/is_volatile_unqualified.hpp>
namespace sprout {
//
// is_cv_unqualified
//
template<typename T>
struct is_cv_unqualified
: public sprout::integral_constant<
bool,
sprout::is_const_unqualified<T>::value && sprout::is_volatile_unqualified<T>::value
>
{};
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_CV_UNQUALIFIED_HPP

View file

@ -5,8 +5,8 @@
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_TYPE_TRAITS_IS_INT_HPP
#define SPROUT_TYPE_TRAITS_IS_INT_HPP
#ifndef SPROUT_TYPE_TRAITS_IS_SINT_HPP
#define SPROUT_TYPE_TRAITS_IS_SINT_HPP
#include <type_traits>
#include <sprout/config.hpp>
@ -14,10 +14,10 @@
namespace sprout {
//
// is_int
// is_sint
//
template<typename T>
struct is_int
struct is_sint
: public sprout::integral_constant<
bool,
std::is_integral<T>::value && std::is_signed<T>::value
@ -26,8 +26,8 @@ namespace sprout {
#if SPROUT_USE_TEMPLATE_ALIASES
template<typename T>
using is_int_t = typename sprout::is_int<T>::type;
using is_sint_t = typename sprout::is_sint<T>::type;
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_INT_HPP
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_SINT_HPP

View file

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2011-2014 Bolero MURAKAMI
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_TYPE_TRAITS_IS_VOLATILE_UNQUALIFIED_HPP
#define SPROUT_TYPE_TRAITS_IS_VOLATILE_UNQUALIFIED_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/integral_constant.hpp>
namespace sprout {
//
// is_volatile_unqualified
//
template<typename T>
struct is_volatile_unqualified
: public sprout::integral_constant<
bool,
std::is_volatile<T>::value
>
{};
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_VOLATILE_UNQUALIFIED_HPP