From f712788ccee51d50dd32e60497c345a7cd51fc5c Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sun, 24 Mar 2013 17:07:20 +0900 Subject: [PATCH] fix README --- README | 2 +- README.md | 2 +- sprout/type_traits.hpp | 5 +++ sprout/type_traits/lvalue_reference.hpp | 8 ++--- sprout/type_traits/remove_cvref.hpp | 24 +++++++++++++ sprout/type_traits/remove_shallow_const.hpp | 27 ++++++++++++++ sprout/type_traits/remove_shallow_cv.hpp | 35 +++++++++++++++++++ sprout/type_traits/remove_shallow_cvref.hpp | 25 +++++++++++++ .../type_traits/remove_shallow_volatile.hpp | 27 ++++++++++++++ sprout/weed/detail/uncvref.hpp | 23 ------------ sprout/weed/expr/make_terminal.hpp | 6 ++-- sprout/weed/expr/make_terminal_or_expr.hpp | 6 ++-- sprout/weed/operator/address_of.hpp | 4 +-- sprout/weed/operator/bitwise_or.hpp | 6 ++-- sprout/weed/operator/dereference.hpp | 4 +-- sprout/weed/operator/logical_not.hpp | 4 +-- sprout/weed/operator/mem_ptr.hpp | 4 +-- sprout/weed/operator/minus.hpp | 6 ++-- sprout/weed/operator/modulus.hpp | 6 ++-- sprout/weed/operator/negate.hpp | 4 +-- sprout/weed/operator/shift_left.hpp | 6 ++-- sprout/weed/operator/unary_plus.hpp | 4 +-- sprout/weed/parser/lit.hpp | 6 ++-- sprout/weed/traits/expr/expr_of.hpp | 4 +-- sprout/weed/traits/expr/terminal_of.hpp | 10 +++--- .../weed/traits/expr/terminal_or_expr_of.hpp | 6 ++-- 26 files changed, 192 insertions(+), 72 deletions(-) create mode 100644 sprout/type_traits/remove_cvref.hpp create mode 100644 sprout/type_traits/remove_shallow_const.hpp create mode 100644 sprout/type_traits/remove_shallow_cv.hpp create mode 100644 sprout/type_traits/remove_shallow_cvref.hpp create mode 100644 sprout/type_traits/remove_shallow_volatile.hpp delete mode 100644 sprout/weed/detail/uncvref.hpp diff --git a/README b/README index 8f387c88..c58edcc0 100644 --- a/README +++ b/README @@ -175,7 +175,7 @@ See: https://github.com/sscrisk/CEL---ConstExpr-Library ## サポートするコンパイラ *(Supported Compilers)* Linux: -* GCC, C++11 mode: 4.7.2 +* GCC, C++11 mode: 4.7.2, 4.8.0 * Clang, C++11 mode: 3.2 diff --git a/README.md b/README.md index 8f387c88..c58edcc0 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ See: https://github.com/sscrisk/CEL---ConstExpr-Library ## サポートするコンパイラ *(Supported Compilers)* Linux: -* GCC, C++11 mode: 4.7.2 +* GCC, C++11 mode: 4.7.2, 4.8.0 * Clang, C++11 mode: 3.2 diff --git a/sprout/type_traits.hpp b/sprout/type_traits.hpp index 79409df4..29b3867d 100644 --- a/sprout/type_traits.hpp +++ b/sprout/type_traits.hpp @@ -9,6 +9,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include diff --git a/sprout/type_traits/lvalue_reference.hpp b/sprout/type_traits/lvalue_reference.hpp index 40e879df..2097bacd 100644 --- a/sprout/type_traits/lvalue_reference.hpp +++ b/sprout/type_traits/lvalue_reference.hpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace sprout { @@ -10,10 +11,9 @@ namespace sprout { // lvalue_reference // template - struct lvalue_reference { - public: - typedef decltype(sprout::as_lvalue(std::declval())) type; - }; + struct lvalue_reference + : public sprout::identity()))> + {}; #if SPROUT_USE_TEMPLATE_ALIASES template diff --git a/sprout/type_traits/remove_cvref.hpp b/sprout/type_traits/remove_cvref.hpp new file mode 100644 index 00000000..2e0b9b95 --- /dev/null +++ b/sprout/type_traits/remove_cvref.hpp @@ -0,0 +1,24 @@ +#ifndef SPROUT_TYPE_TRAITS_REMOVE_CVREF_HPP +#define SPROUT_TYPE_TRAITS_REMOVE_CVREF_HPP + +#include +#include + +namespace sprout { + // + // remove_cvref + // + template + struct remove_cvref + : public std::remove_cv< + typename std::remove_reference::type + > + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using remove_cvref_ = typename sprout::remove_cvref::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_REMOVE_CVREF_HPP diff --git a/sprout/type_traits/remove_shallow_const.hpp b/sprout/type_traits/remove_shallow_const.hpp new file mode 100644 index 00000000..56c5ae45 --- /dev/null +++ b/sprout/type_traits/remove_shallow_const.hpp @@ -0,0 +1,27 @@ +#ifndef SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_CONST_HPP +#define SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_CONST_HPP + +#include +#include +#include + +namespace sprout { + // + // remove_shallow_const + // + template + struct remove_shallow_const + : public sprout::identity + {}; + template + struct remove_shallow_const + : public std::conditional::value, T const, T> + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using remove_shallow_const_ = typename sprout::remove_shallow_const::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_CONST_HPP diff --git a/sprout/type_traits/remove_shallow_cv.hpp b/sprout/type_traits/remove_shallow_cv.hpp new file mode 100644 index 00000000..785690cc --- /dev/null +++ b/sprout/type_traits/remove_shallow_cv.hpp @@ -0,0 +1,35 @@ +#ifndef SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_CV_HPP +#define SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_CV_HPP + +#include +#include +#include + +namespace sprout { + // + // remove_shallow_cv + // + template + struct remove_shallow_cv + : public sprout::identity + {}; + template + struct remove_shallow_cv + : public std::conditional::value, T const, T> + {}; + template + struct remove_shallow_cv + : public std::conditional::value, T volatile, T> + {}; + template + struct remove_shallow_cv + : public std::conditional::value, T const volatile, T> + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using remove_shallow_cv_ = typename sprout::remove_shallow_cv::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_CV_HPP diff --git a/sprout/type_traits/remove_shallow_cvref.hpp b/sprout/type_traits/remove_shallow_cvref.hpp new file mode 100644 index 00000000..f4382853 --- /dev/null +++ b/sprout/type_traits/remove_shallow_cvref.hpp @@ -0,0 +1,25 @@ +#ifndef SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_CVREF_HPP +#define SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_CVREF_HPP + +#include +#include +#include + +namespace sprout { + // + // remove_shallow_cvref + // + template + struct remove_shallow_cvref + : public sprout::remove_shallow_cv< + typename std::remove_reference::type + > + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using remove_shallow_cvref_ = typename sprout::remove_shallow_cvref::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_CVREF_HPP diff --git a/sprout/type_traits/remove_shallow_volatile.hpp b/sprout/type_traits/remove_shallow_volatile.hpp new file mode 100644 index 00000000..6248011a --- /dev/null +++ b/sprout/type_traits/remove_shallow_volatile.hpp @@ -0,0 +1,27 @@ +#ifndef SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_VOLATILE_HPP +#define SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_VOLATILE_HPP + +#include +#include +#include + +namespace sprout { + // + // remove_shallow_volatile + // + template + struct remove_shallow_volatile + : public sprout::identity + {}; + template + struct remove_shallow_volatile + : public std::conditional::value, T volatile, T> + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using remove_shallow_volatile_ = typename sprout::remove_shallow_volatile::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_REMOVE_SHALLOW_VOLATILE_HPP diff --git a/sprout/weed/detail/uncvref.hpp b/sprout/weed/detail/uncvref.hpp deleted file mode 100644 index 2bf6318b..00000000 --- a/sprout/weed/detail/uncvref.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SPROUT_WEED_DETAIL_UNCVREF_HPP -#define SPROUT_WEED_DETAIL_UNCVREF_HPP - -#include -#include - -namespace sprout { - namespace weed { - namespace detail { - template - struct uncvref - : public std::conditional< - std::is_array::value - || std::is_array::type>::value, - typename std::remove_reference::type, - typename std::decay::type - > - {}; - } // namespace detail - } // namespace weed -} // namespace sprout - -#endif // #ifndef SPROUT_WEED_DETAIL_UNCVREF_HPP diff --git a/sprout/weed/expr/make_terminal.hpp b/sprout/weed/expr/make_terminal.hpp index d0cd0bd4..21107357 100644 --- a/sprout/weed/expr/make_terminal.hpp +++ b/sprout/weed/expr/make_terminal.hpp @@ -5,9 +5,9 @@ #include #include #include +#include #include #include -#include namespace sprout { namespace weed { @@ -17,7 +17,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::weed::traits::is_c_str< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value, typename sprout::weed::traits::terminal_of::type >::type make_terminal(Arg&& arg) { @@ -28,7 +28,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::traits::is_c_str< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value, typename sprout::weed::traits::terminal_of::type >::type make_terminal(Arg&& arg) { diff --git a/sprout/weed/expr/make_terminal_or_expr.hpp b/sprout/weed/expr/make_terminal_or_expr.hpp index 01fb4eeb..4070d753 100644 --- a/sprout/weed/expr/make_terminal_or_expr.hpp +++ b/sprout/weed/expr/make_terminal_or_expr.hpp @@ -4,10 +4,10 @@ #include #include #include +#include #include #include #include -#include namespace sprout { namespace weed { @@ -17,7 +17,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::traits::is_expr< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value, typename sprout::weed::traits::terminal_or_expr_of::type >::type make_terminal_or_expr(Arg&& arg) { @@ -26,7 +26,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::weed::traits::is_expr< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value, typename sprout::weed::traits::terminal_or_expr_of::type >::type make_terminal_or_expr(Arg&& arg) { diff --git a/sprout/weed/operator/address_of.hpp b/sprout/weed/operator/address_of.hpp index bc28553b..2bdb56c4 100644 --- a/sprout/weed/operator/address_of.hpp +++ b/sprout/weed/operator/address_of.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -19,7 +19,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/operator/bitwise_or.hpp b/sprout/weed/operator/bitwise_or.hpp index a8549eff..84a0ea2b 100644 --- a/sprout/weed/operator/bitwise_or.hpp +++ b/sprout/weed/operator/bitwise_or.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -20,10 +20,10 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value && sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/operator/dereference.hpp b/sprout/weed/operator/dereference.hpp index 611dcef3..53e32a8b 100644 --- a/sprout/weed/operator/dereference.hpp +++ b/sprout/weed/operator/dereference.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -19,7 +19,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/operator/logical_not.hpp b/sprout/weed/operator/logical_not.hpp index d4ecde2b..eba98198 100644 --- a/sprout/weed/operator/logical_not.hpp +++ b/sprout/weed/operator/logical_not.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -19,7 +19,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/operator/mem_ptr.hpp b/sprout/weed/operator/mem_ptr.hpp index 6849b9f5..7fe8f147 100644 --- a/sprout/weed/operator/mem_ptr.hpp +++ b/sprout/weed/operator/mem_ptr.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -20,7 +20,7 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/operator/minus.hpp b/sprout/weed/operator/minus.hpp index 9557fc9d..9edfff43 100644 --- a/sprout/weed/operator/minus.hpp +++ b/sprout/weed/operator/minus.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -20,10 +20,10 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value && sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/operator/modulus.hpp b/sprout/weed/operator/modulus.hpp index b4eb3e33..e0b380fa 100644 --- a/sprout/weed/operator/modulus.hpp +++ b/sprout/weed/operator/modulus.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -20,10 +20,10 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value && sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/operator/negate.hpp b/sprout/weed/operator/negate.hpp index c07f64cf..a866961a 100644 --- a/sprout/weed/operator/negate.hpp +++ b/sprout/weed/operator/negate.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -19,7 +19,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/operator/shift_left.hpp b/sprout/weed/operator/shift_left.hpp index 673606ab..3124378f 100644 --- a/sprout/weed/operator/shift_left.hpp +++ b/sprout/weed/operator/shift_left.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -20,10 +20,10 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value && sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/operator/unary_plus.hpp b/sprout/weed/operator/unary_plus.hpp index 09e3df92..c0646831 100644 --- a/sprout/weed/operator/unary_plus.hpp +++ b/sprout/weed/operator/unary_plus.hpp @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include namespace sprout { namespace weed { @@ -19,7 +19,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > diff --git a/sprout/weed/parser/lit.hpp b/sprout/weed/parser/lit.hpp index 5c61c1f4..6f96e2ab 100644 --- a/sprout/weed/parser/lit.hpp +++ b/sprout/weed/parser/lit.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include namespace sprout { namespace weed { @@ -17,9 +17,9 @@ namespace sprout { public: template SPROUT_CONSTEXPR typename eval< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::result_type operator()(T&& t) const { - typedef eval::type> eval_type; + typedef eval::type> eval_type; return eval_type()(sprout::forward(t)); } }; diff --git a/sprout/weed/traits/expr/expr_of.hpp b/sprout/weed/traits/expr/expr_of.hpp index 1dca9e05..0f183103 100644 --- a/sprout/weed/traits/expr/expr_of.hpp +++ b/sprout/weed/traits/expr/expr_of.hpp @@ -3,9 +3,9 @@ #include #include +#include #include #include -#include namespace sprout { namespace weed { @@ -19,7 +19,7 @@ namespace sprout { typedef sprout::weed::expr< Tag, typename sprout::weed::traits::terminal_or_expr_of< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::type... > type; }; diff --git a/sprout/weed/traits/expr/terminal_of.hpp b/sprout/weed/traits/expr/terminal_of.hpp index bd9584a2..fdd72f57 100644 --- a/sprout/weed/traits/expr/terminal_of.hpp +++ b/sprout/weed/traits/expr/terminal_of.hpp @@ -3,10 +3,10 @@ #include #include +#include #include #include #include -#include #include namespace sprout { @@ -22,14 +22,14 @@ namespace sprout { Arg, typename std::enable_if< !sprout::weed::traits::is_c_str< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > { public: typedef sprout::weed::expr< sprout::weed::tag::terminal, - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type > type; }; template @@ -37,7 +37,7 @@ namespace sprout { Arg, typename std::enable_if< sprout::weed::traits::is_c_str< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value >::type > { @@ -45,7 +45,7 @@ namespace sprout { typedef sprout::weed::expr< sprout::weed::tag::terminal, typename sprout::weed::detail::c_str_as_string< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::type > type; }; diff --git a/sprout/weed/traits/expr/terminal_or_expr_of.hpp b/sprout/weed/traits/expr/terminal_or_expr_of.hpp index ff2fcf06..4219dbfc 100644 --- a/sprout/weed/traits/expr/terminal_or_expr_of.hpp +++ b/sprout/weed/traits/expr/terminal_or_expr_of.hpp @@ -3,9 +3,9 @@ #include #include +#include #include #include -#include namespace sprout { namespace weed { @@ -18,9 +18,9 @@ namespace sprout { public: typedef typename std::conditional< sprout::weed::traits::is_expr< - typename sprout::weed::detail::uncvref::type + typename sprout::remove_shallow_cvref::type >::value, - typename sprout::weed::detail::uncvref::type, + typename sprout::remove_shallow_cvref::type, typename sprout::weed::traits::terminal_of::type >::type type; };