diff --git a/sprout/type_traits.hpp b/sprout/type_traits.hpp index 75a1db41..7247a443 100644 --- a/sprout/type_traits.hpp +++ b/sprout/type_traits.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #endif // #ifndef SPROUT_TYPE_TRAITS_HPP diff --git a/sprout/type_traits/composite_modification.hpp b/sprout/type_traits/composite_modification.hpp index 8c5b09f4..76908f3a 100644 --- a/sprout/type_traits/composite_modification.hpp +++ b/sprout/type_traits/composite_modification.hpp @@ -16,5 +16,8 @@ #include #include #include +#include +#include +#include #endif // #ifndef SPROUT_TYPE_TRAITS_COMPOSITE_MODIFICATION_HPP diff --git a/sprout/type_traits/copy_const.hpp b/sprout/type_traits/copy_const.hpp new file mode 100644 index 00000000..41d20f1e --- /dev/null +++ b/sprout/type_traits/copy_const.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_COPY_CONST_HPP +#define SPROUT_TYPE_TRAITS_COPY_CONST_HPP + +#include +#include +#include + +namespace sprout { + // + // copy_const + // + template + struct copy_const + : public sprout::identity + {}; + template + struct copy_const + : public std::add_volatile + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using copy_const_t = typename sprout::copy_const::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_COPY_CONST_HPP diff --git a/sprout/type_traits/copy_cv.hpp b/sprout/type_traits/copy_cv.hpp new file mode 100644 index 00000000..0ee05dcf --- /dev/null +++ b/sprout/type_traits/copy_cv.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_COPY_CV_HPP +#define SPROUT_TYPE_TRAITS_COPY_CV_HPP + +#include +#include +#include + +namespace sprout { + // + // copy_cv + // + template + struct copy_cv + : public sprout::identity + {}; + template + struct copy_cv + : public std::add_const + {}; + template + struct copy_cv + : public std::add_volatile + {}; + template + struct copy_cv + : public std::add_cv + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using copy_cv_t = typename sprout::copy_cv::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_COPY_CV_HPP diff --git a/sprout/type_traits/copy_volatile.hpp b/sprout/type_traits/copy_volatile.hpp new file mode 100644 index 00000000..05ea3d25 --- /dev/null +++ b/sprout/type_traits/copy_volatile.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_COPY_VOLATILE_HPP +#define SPROUT_TYPE_TRAITS_COPY_VOLATILE_HPP + +#include +#include +#include + +namespace sprout { + // + // copy_volatile + // + template + struct copy_volatile + : public sprout::identity + {}; + template + struct copy_volatile + : public std::add_volatile + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using copy_volatile_t = typename sprout::copy_volatile::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_COPY_VOLATILE_HPP diff --git a/sprout/type_traits/detail/has_binary_op.hpp b/sprout/type_traits/detail/has_binary_op.hpp new file mode 100644 index 00000000..c988c58e --- /dev/null +++ b/sprout/type_traits/detail/has_binary_op.hpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_DETAIL_HAS_BINARY_OP_HPP +#define SPROUT_TYPE_TRAITS_DETAIL_HAS_BINARY_OP_HPP + +#include +#include +#include +#include +#include +#include +#include + +#define SPROUT_DETAIL_HAS_BINARY_OP_DECL(OP_NAME, OP) \ + template \ + struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test)) { \ + public: \ + template< \ + typename U1 = T1, typename U2 = T2, \ + typename Result = sprout::bool_constant() OP std::declval())>::type, R>::value> \ + > \ + static Result test(int); \ + static sprout::false_type test(...); \ + }; \ + template \ + struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test)) { \ + public: \ + template< \ + typename U1 = T1, typename U2 = T2, \ + typename typename sprout::identity() OP std::declval())>::type \ + > \ + static sprout::true_type test(int); \ + static sprout::false_type test(...); \ + }; \ + SPROUT_DETAIL_HAS_BINARY_OP_DECL_IMPL(OP_NAME); \ + template \ + struct SPROUT_PP_CAT(has_, OP_NAME) \ + : public SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \ + {} + +#if defined(_MSC_VER) && (_MSC_VER > 1900) +# define SPROUT_DETAIL_HAS_BINARY_OP_DECL_IMPL(OP_NAME) \ + template::test(0))>::type> \ + struct SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \ + : public Base_ \ + {} +#else +# define SPROUT_DETAIL_HAS_BINARY_OP_DECL_IMPL(OP_NAME) \ + template \ + struct SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \ + : public sprout::identity::test(0))>::type \ + {} +#endif + +#endif // #ifndef SPROUT_TYPE_TRAITS_DETAIL_HAS_BINARY_OP_HPP diff --git a/sprout/type_traits/detail/has_post_unary_op.hpp b/sprout/type_traits/detail/has_post_unary_op.hpp new file mode 100644 index 00000000..dd1761b9 --- /dev/null +++ b/sprout/type_traits/detail/has_post_unary_op.hpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_DETAIL_HAS_POST_UNARY_OP_HPP +#define SPROUT_TYPE_TRAITS_DETAIL_HAS_POST_UNARY_OP_HPP + +#include +#include +#include +#include +#include +#include +#include + +#define SPROUT_DETAIL_HAS_POST_UNARY_OP_DECL(OP_NAME, OP) \ + template \ + struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test)) { \ + public: \ + template< \ + typename U = T, \ + typename Result = sprout::bool_constant() OP)>::type, R>::value> \ + > \ + static Result test(int); \ + static sprout::false_type test(...); \ + }; \ + template \ + struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test)) { \ + public: \ + template< \ + typename U = T, \ + typename typename sprout::identity() OP)>::type \ + > \ + static sprout::true_type test(int); \ + static sprout::false_type test(...); \ + }; \ + SPROUT_DETAIL_HAS_POST_UNARY_OP_DECL_IMPL(OP_NAME); \ + template \ + struct SPROUT_PP_CAT(has_, OP_NAME) \ + : public SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \ + {} + +#if defined(_MSC_VER) && (_MSC_VER > 1900) +# define SPROUT_DETAIL_HAS_POST_UNARY_OP_DECL_IMPL(OP_NAME) \ + template::test(0))>::type> \ + struct SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \ + : public Base_ \ + {} +#else +# define SPROUT_DETAIL_HAS_POST_UNARY_OP_DECL_IMPL(OP_NAME) \ + template \ + struct SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \ + : public sprout::identity::test(0))>::type \ + {} +#endif + +#endif // #ifndef SPROUT_TYPE_TRAITS_DETAIL_HAS_POST_UNARY_OP_HPP diff --git a/sprout/type_traits/detail/has_pre_unary_op.hpp b/sprout/type_traits/detail/has_pre_unary_op.hpp new file mode 100644 index 00000000..05b570f0 --- /dev/null +++ b/sprout/type_traits/detail/has_pre_unary_op.hpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_DETAIL_HAS_PRE_UNARY_OP_HPP +#define SPROUT_TYPE_TRAITS_DETAIL_HAS_PRE_UNARY_OP_HPP + +#include +#include +#include +#include +#include +#include +#include + +#define SPROUT_DETAIL_HAS_PRE_UNARY_OP_DECL(OP_NAME, OP) \ + template \ + struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test)) { \ + public: \ + template< \ + typename U = T, \ + typename Result = sprout::bool_constant())>::type, R>::value> \ + > \ + static Result test(int); \ + static sprout::false_type test(...); \ + }; \ + template \ + struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test)) { \ + public: \ + template< \ + typename U = T, \ + typename typename sprout::identity())>::type \ + > \ + static sprout::true_type test(int); \ + static sprout::false_type test(...); \ + }; \ + SPROUT_DETAIL_HAS_PRE_UNARY_OP_DECL_IMPL(OP_NAME); \ + template \ + struct SPROUT_PP_CAT(has_, OP_NAME) \ + : public SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \ + {} + +#if defined(_MSC_VER) && (_MSC_VER > 1900) +# define SPROUT_DETAIL_HAS_PRE_UNARY_OP_DECL_IMPL(OP_NAME) \ + template::test(0))>::type> \ + struct SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \ + : public Base_ \ + {} +#else +# define SPROUT_DETAIL_HAS_PRE_UNARY_OP_DECL_IMPL(OP_NAME) \ + template \ + struct SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \ + : public sprout::identity::test(0))>::type \ + {} +#endif + +#endif // #ifndef SPROUT_TYPE_TRAITS_DETAIL_HAS_PRE_UNARY_OP_HPP diff --git a/sprout/type_traits/dont_care.hpp b/sprout/type_traits/dont_care.hpp new file mode 100644 index 00000000..a225f811 --- /dev/null +++ b/sprout/type_traits/dont_care.hpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_DONT_CARE_HPP +#define SPROUT_TYPE_TRAITS_DONT_CARE_HPP + +#include + +namespace sprout { + // + // dont_care + // + struct dont_care {}; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_DONT_CARE_HPP diff --git a/sprout/type_traits/enabler_if.hpp b/sprout/type_traits/enabler_if.hpp index de096f5a..f65ec54f 100644 --- a/sprout/type_traits/enabler_if.hpp +++ b/sprout/type_traits/enabler_if.hpp @@ -25,11 +25,7 @@ namespace sprout { // template class enabler_if -#if defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC) : public std::enable_if -#else - : public std::enable_if -#endif {}; // // disabler_if diff --git a/sprout/type_traits/has_assign.hpp b/sprout/type_traits/has_assign.hpp new file mode 100644 index 00000000..41fd3ac4 --- /dev/null +++ b/sprout/type_traits/has_assign.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_HAS_ASSIGN_HPP +#define SPROUT_TYPE_TRAITS_HAS_ASSIGN_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // has_assign + // + SPROUT_DETAIL_HAS_BINARY_OP_DECL(has_assign, =); + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool has_assign_v = sprout::has_assign::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_ASSIGN_HPP diff --git a/sprout/type_traits/has_operator.hpp b/sprout/type_traits/has_operator.hpp new file mode 100644 index 00000000..9e6d66df --- /dev/null +++ b/sprout/type_traits/has_operator.hpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_LOGICAL_HPP +#define SPROUT_TYPE_TRAITS_LOGICAL_HPP + +#include +#include + +#endif // #ifndef SPROUT_TYPE_TRAITS_LOGICAL_HPP