mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
add copy_cv
This commit is contained in:
parent
1f9db0f1d1
commit
b0f446c959
12 changed files with 356 additions and 4 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/std.hpp>
|
||||
#include <sprout/type_traits/composite_modification.hpp>
|
||||
#include <sprout/type_traits/has_operator.hpp>
|
||||
#include <sprout/type_traits/introspection.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HPP
|
||||
|
|
|
@ -16,5 +16,8 @@
|
|||
#include <sprout/type_traits/remove_shallow_volatile.hpp>
|
||||
#include <sprout/type_traits/remove_shallow_cv.hpp>
|
||||
#include <sprout/type_traits/remove_shallow_cvref.hpp>
|
||||
#include <sprout/type_traits/copy_const.hpp>
|
||||
#include <sprout/type_traits/copy_volatile.hpp>
|
||||
#include <sprout/type_traits/copy_cv.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_COMPOSITE_MODIFICATION_HPP
|
||||
|
|
34
sprout/type_traits/copy_const.hpp
Normal file
34
sprout/type_traits/copy_const.hpp
Normal file
|
@ -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 <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// copy_const
|
||||
//
|
||||
template<typename T, typename U>
|
||||
struct copy_const
|
||||
: public sprout::identity<T>
|
||||
{};
|
||||
template<typename T, typename U>
|
||||
struct copy_const<T, U volatile>
|
||||
: public std::add_volatile<T>
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename U>
|
||||
using copy_const_t = typename sprout::copy_const<T, U>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_COPY_CONST_HPP
|
42
sprout/type_traits/copy_cv.hpp
Normal file
42
sprout/type_traits/copy_cv.hpp
Normal file
|
@ -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 <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// copy_cv
|
||||
//
|
||||
template<typename T, typename U>
|
||||
struct copy_cv
|
||||
: public sprout::identity<T>
|
||||
{};
|
||||
template<typename T, typename U>
|
||||
struct copy_cv<T, U const>
|
||||
: public std::add_const<T>
|
||||
{};
|
||||
template<typename T, typename U>
|
||||
struct copy_cv<T, U volatile>
|
||||
: public std::add_volatile<T>
|
||||
{};
|
||||
template<typename T, typename U>
|
||||
struct copy_cv<T, U const volatile>
|
||||
: public std::add_cv<T>
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename U>
|
||||
using copy_cv_t = typename sprout::copy_cv<T, U>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_COPY_CV_HPP
|
34
sprout/type_traits/copy_volatile.hpp
Normal file
34
sprout/type_traits/copy_volatile.hpp
Normal file
|
@ -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 <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// copy_volatile
|
||||
//
|
||||
template<typename T, typename U>
|
||||
struct copy_volatile
|
||||
: public sprout::identity<T>
|
||||
{};
|
||||
template<typename T, typename U>
|
||||
struct copy_volatile<T, U volatile>
|
||||
: public std::add_volatile<T>
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename U>
|
||||
using copy_volatile_t = typename sprout::copy_volatile<T, U>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_COPY_VOLATILE_HPP
|
60
sprout/type_traits/detail/has_binary_op.hpp
Normal file
60
sprout/type_traits/detail/has_binary_op.hpp
Normal file
|
@ -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 <utility>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/type_traits/dont_care.hpp>
|
||||
#include <sprout/preprocessor/cat.hpp>
|
||||
|
||||
#define SPROUT_DETAIL_HAS_BINARY_OP_DECL(OP_NAME, OP) \
|
||||
template<typename T1, typename T2, typename R> \
|
||||
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<std::is_convertible<typename sprout::identity<decltype(std::declval<U1>() OP std::declval<U2>())>::type, R>::value> \
|
||||
> \
|
||||
static Result test(int); \
|
||||
static sprout::false_type test(...); \
|
||||
}; \
|
||||
template<typename T1, typename T2> \
|
||||
struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test))<T1, T2, sprout::dont_care> { \
|
||||
public: \
|
||||
template< \
|
||||
typename U1 = T1, typename U2 = T2, \
|
||||
typename typename sprout::identity<decltype(std::declval<U1>() OP std::declval<U2>())>::type \
|
||||
> \
|
||||
static sprout::true_type test(int); \
|
||||
static sprout::false_type test(...); \
|
||||
}; \
|
||||
SPROUT_DETAIL_HAS_BINARY_OP_DECL_IMPL(OP_NAME); \
|
||||
template<typename T, typename U, typename R = sprout::dont_care> \
|
||||
struct SPROUT_PP_CAT(has_, OP_NAME) \
|
||||
: public SPROUT_PP_CAT(sprout_detail_has_, OP_NAME)<T, U, R> \
|
||||
{}
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1900)
|
||||
# define SPROUT_DETAIL_HAS_BINARY_OP_DECL_IMPL(OP_NAME) \
|
||||
template<typename T, typename U, typename R, typename Base_ = typename sprout::identity<decltype(SPROUT_PP_CAT(sprout_detail_has_, OP_NAME)<T, U, R>::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<typename T, typename U, typename R> \
|
||||
struct SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \
|
||||
: public sprout::identity<decltype(SPROUT_PP_CAT(sprout_detail_has_, OP_NAME)<T, U, R>::test(0))>::type \
|
||||
{}
|
||||
#endif
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_DETAIL_HAS_BINARY_OP_HPP
|
60
sprout/type_traits/detail/has_post_unary_op.hpp
Normal file
60
sprout/type_traits/detail/has_post_unary_op.hpp
Normal file
|
@ -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 <utility>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/type_traits/dont_care.hpp>
|
||||
#include <sprout/preprocessor/cat.hpp>
|
||||
|
||||
#define SPROUT_DETAIL_HAS_POST_UNARY_OP_DECL(OP_NAME, OP) \
|
||||
template<typename T, typename R> \
|
||||
struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test)) { \
|
||||
public: \
|
||||
template< \
|
||||
typename U = T, \
|
||||
typename Result = sprout::bool_constant<std::is_convertible<typename sprout::identity<decltype(std::declval<U>() OP)>::type, R>::value> \
|
||||
> \
|
||||
static Result test(int); \
|
||||
static sprout::false_type test(...); \
|
||||
}; \
|
||||
template<typename T> \
|
||||
struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test))<T, sprout::dont_care> { \
|
||||
public: \
|
||||
template< \
|
||||
typename U = T, \
|
||||
typename typename sprout::identity<decltype(std::declval<U>() OP)>::type \
|
||||
> \
|
||||
static sprout::true_type test(int); \
|
||||
static sprout::false_type test(...); \
|
||||
}; \
|
||||
SPROUT_DETAIL_HAS_POST_UNARY_OP_DECL_IMPL(OP_NAME); \
|
||||
template<typename T, typename R = sprout::dont_care> \
|
||||
struct SPROUT_PP_CAT(has_, OP_NAME) \
|
||||
: public SPROUT_PP_CAT(sprout_detail_has_, OP_NAME)<T, R> \
|
||||
{}
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1900)
|
||||
# define SPROUT_DETAIL_HAS_POST_UNARY_OP_DECL_IMPL(OP_NAME) \
|
||||
template<typename T, typename R, typename Base_ = typename sprout::identity<decltype(SPROUT_PP_CAT(sprout_detail_has_, OP_NAME)<T, R>::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<typename T, typename R> \
|
||||
struct SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \
|
||||
: public sprout::identity<decltype(SPROUT_PP_CAT(sprout_detail_has_, OP_NAME)<T, R>::test(0))>::type \
|
||||
{}
|
||||
#endif
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_DETAIL_HAS_POST_UNARY_OP_HPP
|
60
sprout/type_traits/detail/has_pre_unary_op.hpp
Normal file
60
sprout/type_traits/detail/has_pre_unary_op.hpp
Normal file
|
@ -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 <utility>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/type_traits/dont_care.hpp>
|
||||
#include <sprout/preprocessor/cat.hpp>
|
||||
|
||||
#define SPROUT_DETAIL_HAS_PRE_UNARY_OP_DECL(OP_NAME, OP) \
|
||||
template<typename T, typename R> \
|
||||
struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test)) { \
|
||||
public: \
|
||||
template< \
|
||||
typename U = T, \
|
||||
typename Result = sprout::bool_constant<std::is_convertible<typename sprout::identity<decltype(OP std::declval<U>())>::type, R>::value> \
|
||||
> \
|
||||
static Result test(int); \
|
||||
static sprout::false_type test(...); \
|
||||
}; \
|
||||
template<typename T> \
|
||||
struct SPROUT_PP_CAT(sprout_detail_has_, SPROUT_PP_CAT(OP_NAME, _test))<T, sprout::dont_care> { \
|
||||
public: \
|
||||
template< \
|
||||
typename U = T, \
|
||||
typename typename sprout::identity<decltype(OP std::declval<U>())>::type \
|
||||
> \
|
||||
static sprout::true_type test(int); \
|
||||
static sprout::false_type test(...); \
|
||||
}; \
|
||||
SPROUT_DETAIL_HAS_PRE_UNARY_OP_DECL_IMPL(OP_NAME); \
|
||||
template<typename T, typename R = sprout::dont_care> \
|
||||
struct SPROUT_PP_CAT(has_, OP_NAME) \
|
||||
: public SPROUT_PP_CAT(sprout_detail_has_, OP_NAME)<T, R> \
|
||||
{}
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1900)
|
||||
# define SPROUT_DETAIL_HAS_PRE_UNARY_OP_DECL_IMPL(OP_NAME) \
|
||||
template<typename T, typename R, typename Base_ = typename sprout::identity<decltype(SPROUT_PP_CAT(sprout_detail_has_, OP_NAME)<T, R>::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<typename T, typename R> \
|
||||
struct SPROUT_PP_CAT(sprout_detail_has_, OP_NAME) \
|
||||
: public sprout::identity<decltype(SPROUT_PP_CAT(sprout_detail_has_, OP_NAME)<T, R>::test(0))>::type \
|
||||
{}
|
||||
#endif
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_DETAIL_HAS_PRE_UNARY_OP_HPP
|
20
sprout/type_traits/dont_care.hpp
Normal file
20
sprout/type_traits/dont_care.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// dont_care
|
||||
//
|
||||
struct dont_care {};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_DONT_CARE_HPP
|
|
@ -25,11 +25,7 @@ namespace sprout {
|
|||
//
|
||||
template<bool C>
|
||||
class enabler_if
|
||||
#if defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
|
||||
: public std::enable_if<C, sprout::enabler_t>
|
||||
#else
|
||||
: public std::enable_if<C, sprout::enabler_t&>
|
||||
#endif
|
||||
{};
|
||||
//
|
||||
// disabler_if
|
||||
|
|
28
sprout/type_traits/has_assign.hpp
Normal file
28
sprout/type_traits/has_assign.hpp
Normal file
|
@ -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 <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/dont_care.hpp>
|
||||
#include <sprout/type_traits/detail/has_binary_op.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// has_assign
|
||||
//
|
||||
SPROUT_DETAIL_HAS_BINARY_OP_DECL(has_assign, =);
|
||||
|
||||
#if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
template<typename T, typename U, typename R = sprout::dont_care>
|
||||
SPROUT_STATIC_CONSTEXPR bool has_assign_v = sprout::has_assign<T, U, R>::value;
|
||||
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_ASSIGN_HPP
|
14
sprout/type_traits/has_operator.hpp
Normal file
14
sprout/type_traits/has_operator.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_assign.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_LOGICAL_HPP
|
Loading…
Reference in a new issue