1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00

supprt for VC++2015

This commit is contained in:
bolero-MURAKAMI 2016-02-12 11:24:46 +09:00
parent 7af7bbee05
commit b1b62d9a29
3 changed files with 86 additions and 23 deletions

View file

@ -0,0 +1,30 @@
/*=============================================================================
Copyright (c) 2011-2015 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_DETAIL_ONE_TYPE_HPP
#define SPROUT_DETAIL_ONE_TYPE_HPP
#include <sprout/config.hpp>
namespace sprout {
namespace detail {
//
// one_type
//
typedef char one_type;
//
// not_one_type
//
struct not_one_type {
public:
char padding[8];
};
} // namespace detail
} // namespace sprout
#endif // #ifndef SPROUT_DETAIL_ONE_TYPE_HPP

View file

@ -8,12 +8,16 @@
#ifndef SPROUT_TYPE_TRAITS_HAS_XXX_HPP #ifndef SPROUT_TYPE_TRAITS_HAS_XXX_HPP
#define SPROUT_TYPE_TRAITS_HAS_XXX_HPP #define SPROUT_TYPE_TRAITS_HAS_XXX_HPP
#include <sprout/config.hpp> #include <type_traits>
#include <sprout/detail/one_type.hpp>
#include <sprout/preprocessor/cat.hpp> #include <sprout/preprocessor/cat.hpp>
#include <sprout/preprocessor/some_number.hpp> #include <sprout/preprocessor/some_number.hpp>
#include <sprout/type_traits/identity.hpp> #include <sprout/type_traits/identity.hpp>
#include <sprout/type_traits/integral_constant.hpp> #include <sprout/type_traits/integral_constant.hpp>
#define SPROUT_HAS_XXX_DETAIL_NAME_GEN(PREFIX, ELEM, NAME, NUM) \
SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(PREFIX, ELEM), NAME), NUM)
// //
// SPROUT_HAS_XXX_TYPE_DEF // SPROUT_HAS_XXX_TYPE_DEF
// SPROUT_HAS_XXX_TYPE_DEF_LAZY // SPROUT_HAS_XXX_TYPE_DEF_LAZY
@ -21,22 +25,22 @@
#if defined(_MSC_VER) && (_MSC_VER > 1900) #if defined(_MSC_VER) && (_MSC_VER > 1900)
#define SPROUT_HAS_XXX_TYPE_DEF_IMPL(NAME, TYPE, NUM) \ #define SPROUT_HAS_XXX_TYPE_DEF_IMPL(NAME, TYPE, NUM) \
template<typename T, typename = typename T::TYPE> \ template<typename T, typename = typename T::TYPE> \
sprout::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), NUM)(int); \ sprout::true_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TYPE, NAME, NUM)(int); \
template<typename T> \ template<typename T> \
sprout::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), NUM)(long); \ sprout::false_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TYPE, NAME, NUM)(long); \
template<typename T, typename Base_ = decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), NUM)<T>(0))> \ template<typename T, typename Base_ = decltype(SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TYPE, NAME, NUM)<T>(0))> \
struct NAME \ struct NAME \
: public Base_ \ : public Base_ \
{} {}
#else #else
#define SPROUT_HAS_XXX_TYPE_DEF_IMPL(NAME, TYPE, NUM) \ #define SPROUT_HAS_XXX_TYPE_DEF_IMPL(NAME, TYPE, NUM) \
template<typename T, typename = typename T::TYPE> \ template<typename T, typename = typename T::TYPE> \
sprout::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), NUM)(int); \ sprout::true_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TYPE, NAME, NUM)(int); \
template<typename T> \ template<typename T> \
sprout::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), NUM)(long); \ sprout::false_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TYPE, NAME, NUM)(long); \
template<typename T> \ template<typename T> \
struct NAME \ struct NAME \
: public sprout::identity<decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TYPE), NAME), NUM)<T>(0))>::type \ : public sprout::identity<decltype(SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TYPE, NAME, NUM)<T>(0))>::type \
{} {}
#endif #endif
#define SPROUT_HAS_XXX_TYPE_DEF(NAME, TYPE) \ #define SPROUT_HAS_XXX_TYPE_DEF(NAME, TYPE) \
@ -48,25 +52,50 @@
// SPROUT_HAS_XXX_VALUE_DEF // SPROUT_HAS_XXX_VALUE_DEF
// SPROUT_HAS_XXX_VALUE_DEF_LAZY // SPROUT_HAS_XXX_VALUE_DEF_LAZY
// //
#if defined(_MSC_VER) && (_MSC_VER > 1900) #if defined(_MSC_VER)
#define SPROUT_HAS_XXX_VALUE_DEF_IMPL(NAME, VALUE, NUM) \ #define SPROUT_HAS_XXX_VALUE_DEF_IMPL_HSD_OP(NAME, VALUE, NUM) \
template<typename T, typename sprout::identity<decltype(&T::VALUE)>::type = &T::VALUE> \ template<typename T> \
sprout::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), NUM)(int); \ struct SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_value_hsd_op_, VALUE, NAME, NUM) { \
private: \
template<typename U, typename V> \
static sprout::detail::one_type check2(V*); \
template<typename U, typename V> \
static sprout::detail::not_one_type check2(U); \
private: \
template<typename U> \
static typename std::enable_if< \
sizeof(check2<U, decltype(U::VALUE)>(&U::VALUE)) == sizeof(sprout::detail::one_type), \
sprout::detail::one_type \
>::type has_matching_member(int); \
template<typename U> \
static sprout::detail::not_one_type has_matching_member(...); \
private: \
template<typename U> \
struct ttc_sd \
: public sprout::bool_constant<sizeof(has_matching_member<U>(0)) == sizeof(sprout::detail::one_type)> \
{}; \
public: \
typedef typename ttc_sd<T>::type type; \
}
#define SPROUT_HAS_XXX_VALUE_DEF_IMPL(NAME, VALUE, NUM) \
SPROUT_HAS_XXX_VALUE_DEF_IMPL_HSD_OP(NAME, VALUE, NUM); \
template<typename T> \ template<typename T> \
sprout::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), NUM)(long); \
template<typename T, typename Base_ = decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), NUM)<T>(0))> \
struct NAME \ struct NAME \
: public Base_ \ : public std::conditional< \
std::is_class<T>::value, \
SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_value_hsd_op_, VALUE, NAME, NUM)<T>, \
sprout::false_type \
>::type::type \
{} {}
#else #else
#define SPROUT_HAS_XXX_VALUE_DEF_IMPL(NAME, VALUE, NUM) \ #define SPROUT_HAS_XXX_VALUE_DEF_IMPL(NAME, VALUE, NUM) \
template<typename T, typename sprout::identity<decltype(&T::VALUE)>::type = &T::VALUE> \ template<typename T, typename sprout::identity<decltype(&T::VALUE)>::type = &T::VALUE> \
sprout::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), NUM)(int); \ sprout::true_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_value_, VALUE, NAME, NUM)(int); \
template<typename T> \ template<typename T> \
sprout::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), NUM)(long); \ sprout::false_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_value_, VALUE, NAME, NUM)(long); \
template<typename T> \ template<typename T> \
struct NAME \ struct NAME \
: public sprout::identity<decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_value_, VALUE), NAME), NUM)<T>(0))>::type \ : public sprout::identity<decltype(SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_value_, VALUE, NAME, NUM)<T>(0))>::type \
{} {}
#endif #endif
#define SPROUT_HAS_XXX_VALUE_DEF(NAME, VALUE) \ #define SPROUT_HAS_XXX_VALUE_DEF(NAME, VALUE) \
@ -81,22 +110,22 @@
#if defined(_MSC_VER) && (_MSC_VER > 1900) #if defined(_MSC_VER) && (_MSC_VER > 1900)
#define SPROUT_HAS_XXX_TEMPLATE_DEF_IMPL(NAME, TEMPLATE, NUM) \ #define SPROUT_HAS_XXX_TEMPLATE_DEF_IMPL(NAME, TEMPLATE, NUM) \
template<typename T, template<typename...> class = T::template TEMPLATE> \ template<typename T, template<typename...> class = T::template TEMPLATE> \
sprout::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TEMPLATE), NAME), NUM)(int); \ sprout::true_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TEMPLATE, NAME, NUM)(int); \
template<typename T> \ template<typename T> \
sprout::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TEMPLATE), NAME), NUM)(long); \ sprout::false_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TEMPLATE, NAME, NUM)(long); \
template<typename T, typename Base_ = decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TEMPLATE), NAME), NUM)<T>(0))> \ template<typename T, typename Base_ = decltype(SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TEMPLATE, NAME, NUM)<T>(0))> \
struct NAME \ struct NAME \
: public Base_ \ : public Base_ \
{} {}
#else #else
#define SPROUT_HAS_XXX_TEMPLATE_DEF_IMPL(NAME, TEMPLATE, NUM) \ #define SPROUT_HAS_XXX_TEMPLATE_DEF_IMPL(NAME, TEMPLATE, NUM) \
template<typename T, template<typename...> class = T::template TEMPLATE> \ template<typename T, template<typename...> class = T::template TEMPLATE> \
sprout::true_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TEMPLATE), NAME), NUM)(int); \ sprout::true_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TEMPLATE, NAME, NUM)(int); \
template<typename T> \ template<typename T> \
sprout::false_type SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TEMPLATE), NAME), NUM)(long); \ sprout::false_type SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TEMPLATE, NAME, NUM)(long); \
template<typename T> \ template<typename T> \
struct NAME \ struct NAME \
: public sprout::identity<decltype(SPROUT_PP_CAT(SPROUT_PP_CAT(SPROUT_PP_CAT(sprout_has_xxx_impl_check_type_, TEMPLATE), NAME), NUM)<T>(0))>::type \ : public sprout::identity<decltype(SPROUT_HAS_XXX_DETAIL_NAME_GEN(sprout_has_xxx_impl_check_type_, TEMPLATE, NAME, NUM)<T>(0))>::type \
{} {}
#endif #endif
#define SPROUT_HAS_XXX_TEMPLATE_DEF(NAME, TEMPLATE) \ #define SPROUT_HAS_XXX_TEMPLATE_DEF(NAME, TEMPLATE) \

View file

@ -23,6 +23,8 @@ namespace sprout {
typedef typename std::integral_constant<T, V>::value_type value_type; typedef typename std::integral_constant<T, V>::value_type value_type;
typedef integral_constant type; typedef integral_constant type;
public: public:
SPROUT_STATIC_CONSTEXPR value_type value = V;
public:
#if defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC) #if defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
SPROUT_CONSTEXPR integral_constant() SPROUT_NOEXCEPT {} SPROUT_CONSTEXPR integral_constant() SPROUT_NOEXCEPT {}
integral_constant(integral_constant const&) = default; integral_constant(integral_constant const&) = default;
@ -40,6 +42,8 @@ namespace sprout {
return std::integral_constant<T, V>::value; return std::integral_constant<T, V>::value;
} }
}; };
template<typename T, T V>
SPROUT_CONSTEXPR_OR_CONST typename sprout::integral_constant<T, V>::value_type sprout::integral_constant<T, V>::value;
// //
// bool_constant // bool_constant