From c78e1d0e6d8c9dd5f7d31efd97d25dd43b20edb2 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Mon, 25 Mar 2013 12:43:47 +0900 Subject: [PATCH] fix weed type_traits --- sprout/type_traits/float_promote.hpp | 12 +-- sprout/type_traits/is_c_str.hpp | 16 ---- sprout/weed/attr_cnv/result_of/bitwise_or.hpp | 76 ++++++++---------- sprout/weed/attr_cnv/result_of/negate.hpp | 8 +- sprout/weed/attr_cnv/result_of/shift_left.hpp | 80 ++++++++----------- sprout/weed/attr_cnv/result_of/times.hpp | 26 +++--- sprout/weed/detail/c_str_as_string.hpp | 32 +++++++- sprout/weed/parser/auxiliary/eoi.hpp | 15 ++-- sprout/weed/parser/auxiliary/eol.hpp | 15 ++-- sprout/weed/parser/auxiliary/eps.hpp | 15 ++-- sprout/weed/parser/char/char.hpp | 43 +++++----- sprout/weed/parser/char/char_class.hpp | 17 ++-- sprout/weed/parser/directive/as_array.hpp | 8 +- sprout/weed/parser/directive/as_tuple.hpp | 8 +- sprout/weed/parser/directive/omit.hpp | 15 ++-- sprout/weed/parser/directive/repeat.hpp | 17 ++-- sprout/weed/parser/directive/replace.hpp | 15 ++-- sprout/weed/parser/lim.hpp | 15 ++-- sprout/weed/parser/numeric/int_p.hpp | 15 ++-- sprout/weed/parser/numeric/uint_p.hpp | 15 ++-- sprout/weed/parser/string/string.hpp | 29 +++---- sprout/weed/traits/expr/expr_of.hpp | 20 ++--- sprout/weed/traits/expr/tag_of.hpp | 8 +- sprout/weed/traits/expr/terminal_of.hpp | 35 ++++---- .../weed/traits/expr/terminal_or_expr_of.hpp | 13 ++- sprout/weed/traits/parser/attribute_of.hpp | 15 ++-- sprout/weed/traits/parser/is_parser.hpp | 2 +- 27 files changed, 279 insertions(+), 306 deletions(-) diff --git a/sprout/type_traits/float_promote.hpp b/sprout/type_traits/float_promote.hpp index dbb2742a..d82fee6a 100644 --- a/sprout/type_traits/float_promote.hpp +++ b/sprout/type_traits/float_promote.hpp @@ -11,9 +11,9 @@ namespace sprout { struct float_promote1 : public std::conditional< std::is_floating_point::value, - sprout::identity, - sprout::identity - >::type + T, + double + > { static_assert( std::is_arithmetic::value, @@ -25,13 +25,13 @@ namespace sprout { struct float_promote2 : public std::conditional< (std::is_same::value || std::is_same::value), - sprout::identity, + long double, typename std::conditional< (std::is_same::value && std::is_same::value), float, double - > - >::type + >::type + > { static_assert( std::is_arithmetic::value && std::is_arithmetic::value, diff --git a/sprout/type_traits/is_c_str.hpp b/sprout/type_traits/is_c_str.hpp index 757e52ac..5553bbd1 100644 --- a/sprout/type_traits/is_c_str.hpp +++ b/sprout/type_traits/is_c_str.hpp @@ -40,22 +40,6 @@ namespace sprout { struct is_c_str : public std::true_type {}; - template - struct is_c_str - : public std::true_type - {}; - template - struct is_c_str - : public std::true_type - {}; - template - struct is_c_str - : public std::true_type - {}; - template - struct is_c_str - : public std::true_type - {}; #if SPROUT_USE_TEMPLATE_ALIASES template diff --git a/sprout/weed/attr_cnv/result_of/bitwise_or.hpp b/sprout/weed/attr_cnv/result_of/bitwise_or.hpp index f8f734ea..22c85467 100644 --- a/sprout/weed/attr_cnv/result_of/bitwise_or.hpp +++ b/sprout/weed/attr_cnv/result_of/bitwise_or.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -36,14 +37,13 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_same_container::value >::type - > { - public: - typedef typename std::conditional< + > + : public std::conditional< !(sprout::tuples::tuple_size::value < sprout::tuples::tuple_size::value), T, U - >::type type; - }; + > + {}; // container | V -> container template struct bitwise_or< @@ -52,14 +52,13 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_container_and_elem::value >::type - > { - public: - typedef typename std::conditional< + > + : public std::conditional< sprout::container_traits::static_size != 0, T, typename sprout::container_transform_traits::template rebind_size<1>::type - >::type type; - }; + > + {}; // V | container -> container template struct bitwise_or< @@ -68,14 +67,13 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_elem_and_container::value >::type - > { - public: - typedef typename std::conditional< + > + : public std::conditional< sprout::container_traits::static_size != 0, U, typename sprout::container_transform_traits::template rebind_size<1>::type - >::type type; - }; + > + {}; // tuple | tuple -> tuple template struct bitwise_or< @@ -84,14 +82,13 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_both_tuple::value >::type - > { - public: - typedef typename std::conditional< + > + : public std::conditional< !(sprout::tuples::tuple_size::value < sprout::tuples::tuple_size::value), T, U - >::type type; - }; + > + {}; // V | V -> V template struct bitwise_or< @@ -100,10 +97,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_same_elem::value >::type - > { - public: - typedef T type; - }; + > + : public sprout::identity + {}; // V | W -> variant template struct bitwise_or< @@ -112,10 +108,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_different_elem::value >::type - > { - public: - typedef sprout::variant type; - }; + > + : public sprout::identity > + {}; // V | unused -> container template struct bitwise_or< @@ -124,14 +119,13 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_elem_and_unused::value >::type - > { - public: - typedef typename std::conditional< + > + : public std::conditional< sprout::weed::traits::is_char_type::value, sprout::basic_string, sprout::array - >::type type; - }; + > + {}; // unused | V -> container template struct bitwise_or< @@ -140,14 +134,13 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_unused_and_elem::value >::type - > { - public: - typedef typename std::conditional< + > + : public std::conditional< sprout::weed::traits::is_char_type::value, sprout::basic_string, sprout::array - >::type type; - }; + > + {}; // unused | unused -> unused template struct bitwise_or< @@ -156,10 +149,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_both_unused::value >::type - > { - public: - typedef sprout::weed::unused type; - }; + > + : public sprout::identity + {}; } // namespace result_of } // namespace attr_cnv } // namespace weed diff --git a/sprout/weed/attr_cnv/result_of/negate.hpp b/sprout/weed/attr_cnv/result_of/negate.hpp index 226d9848..a6c5bb73 100644 --- a/sprout/weed/attr_cnv/result_of/negate.hpp +++ b/sprout/weed/attr_cnv/result_of/negate.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -22,10 +23,9 @@ namespace sprout { typename std::enable_if< sprout::weed::traits::is_unused::value >::type - > { - public: - typedef sprout::weed::unused type; - }; + > + : public sprout::identity + {}; } // namespace result_of } // namespace attr_cnv } // namespace weed diff --git a/sprout/weed/attr_cnv/result_of/shift_left.hpp b/sprout/weed/attr_cnv/result_of/shift_left.hpp index 5167b3c6..e5793a39 100644 --- a/sprout/weed/attr_cnv/result_of/shift_left.hpp +++ b/sprout/weed/attr_cnv/result_of/shift_left.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -42,10 +43,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_same_container::value >::type - > { - public: - typedef typename sprout::fixed::result_of::append_back::type type; - }; + > + : public sprout::fixed::result_of::append_back + {}; // container >> V -> container template struct shift_left< @@ -54,10 +54,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_container_and_elem::value >::type - > { - public: - typedef typename sprout::fixed::result_of::push_back::type type; - }; + > + : public sprout::fixed::result_of::push_back + {}; // V >> container -> container template struct shift_left< @@ -66,10 +65,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_elem_and_container::value >::type - > { - public: - typedef typename sprout::fixed::result_of::push_front::type type; - }; + > + : public sprout::fixed::result_of::push_front + {}; // tuple >> tuple -> tuple template struct shift_left< @@ -78,10 +76,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_both_tuple::value >::type - > { - public: - typedef typename sprout::tuples::result_of::append_back::type type; - }; + > + : public sprout::tuples::result_of::append_back + {}; // tuple >> V -> tuple template struct shift_left< @@ -90,10 +87,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_tuple_and_elem::value >::type - > { - public: - typedef typename sprout::tuples::result_of::push_back::type type; - }; + > + : public sprout::tuples::result_of::push_back + {}; // V >> tuple -> tuple template struct shift_left< @@ -102,10 +98,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_elem_and_tuple::value >::type - > { - public: - typedef typename sprout::tuples::result_of::push_front::type type; - }; + > + : public sprout::tuples::result_of::push_front + {}; // V >> V -> container template struct shift_left< @@ -114,14 +109,13 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_same_elem::value >::type - > { - public: - typedef typename std::conditional< + > + : public std::conditional< sprout::weed::traits::is_char_type::value, sprout::basic_string, sprout::array - >::type type; - }; + > + {}; // V >> W -> tuple template struct shift_left< @@ -130,10 +124,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_different_elem::value >::type - > { - public: - typedef sprout::tuples::tuple type; - }; + > + : public sprout::identity > + {}; // V >> unused -> V template struct shift_left< @@ -142,10 +135,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_elem_and_unused::value >::type - > { - public: - typedef T type; - }; + > + : public sprout::identity + {}; // unused >> V -> V template struct shift_left< @@ -154,10 +146,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_unused_and_elem::value >::type - > { - public: - typedef U type; - }; + > + : public sprout::identity + {}; // unused >> unused -> unused template struct shift_left< @@ -166,10 +157,9 @@ namespace sprout { typename std::enable_if< sprout::weed::detail::is_both_unused::value >::type - > { - public: - typedef sprout::weed::unused type; - }; + > + : public sprout::identity + {}; } // namespace result_of } // namespace attr_cnv } // namespace weed diff --git a/sprout/weed/attr_cnv/result_of/times.hpp b/sprout/weed/attr_cnv/result_of/times.hpp index 5ec3ab4f..2b49de43 100644 --- a/sprout/weed/attr_cnv/result_of/times.hpp +++ b/sprout/weed/attr_cnv/result_of/times.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -30,12 +31,11 @@ namespace sprout { Limit != std::size_t(-1) && sprout::weed::traits::is_container::value >::type - > { - public: - typedef typename sprout::algorithm::result_of::join< + > + : public sprout::algorithm::result_of::join< sprout::array - >::type type; - }; + > + {}; // times(V) -> container template struct times< @@ -46,14 +46,13 @@ namespace sprout { && !sprout::weed::traits::is_container::value && !sprout::weed::traits::is_unused::value >::type - > { - public: - typedef typename std::conditional< + > + : public std::conditional< sprout::weed::traits::is_char_type::value, sprout::basic_string, sprout::array - >::type type; - }; + > + {}; // times(unused) -> unused template struct times< @@ -62,10 +61,9 @@ namespace sprout { typename std::enable_if< sprout::weed::traits::is_unused::value >::type - > { - public: - typedef sprout::weed::unused type; - }; + > + : public sprout::identity + {}; } // namespace result_of } // namespace attr_cnv } // namespace weed diff --git a/sprout/weed/detail/c_str_as_string.hpp b/sprout/weed/detail/c_str_as_string.hpp index 3135c6a9..fffe3725 100644 --- a/sprout/weed/detail/c_str_as_string.hpp +++ b/sprout/weed/detail/c_str_as_string.hpp @@ -4,17 +4,41 @@ #include #include #include +#include namespace sprout { namespace weed { namespace detail { template struct c_str_as_string; + template + struct c_str_as_string + : public sprout::weed::detail::c_str_as_string + {}; + template + struct c_str_as_string + : public sprout::weed::detail::c_str_as_string + {}; + template + struct c_str_as_string + : public sprout::weed::detail::c_str_as_string + {}; template - struct c_str_as_string { - public: - typedef sprout::basic_string type; - }; + struct c_str_as_string + : public sprout::identity > + {}; + template + struct c_str_as_string + : public sprout::identity > + {}; + template + struct c_str_as_string + : public sprout::identity > + {}; + template + struct c_str_as_string + : public sprout::identity > + {}; } // namespace detail } // namespace weed } // namespace sprout diff --git a/sprout/weed/parser/auxiliary/eoi.hpp b/sprout/weed/parser/auxiliary/eoi.hpp index 73fe34d5..97584651 100644 --- a/sprout/weed/parser/auxiliary/eoi.hpp +++ b/sprout/weed/parser/auxiliary/eoi.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -17,15 +18,13 @@ namespace sprout { { public: template - struct attribute { - public: - typedef sprout::weed::unused type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; public: template SPROUT_CONSTEXPR typename result::type operator()( diff --git a/sprout/weed/parser/auxiliary/eol.hpp b/sprout/weed/parser/auxiliary/eol.hpp index 9822e72d..0f761b9b 100644 --- a/sprout/weed/parser/auxiliary/eol.hpp +++ b/sprout/weed/parser/auxiliary/eol.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -18,15 +19,13 @@ namespace sprout { { public: template - struct attribute { - public: - typedef sprout::weed::unused type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; public: template SPROUT_CONSTEXPR typename result::type operator()( diff --git a/sprout/weed/parser/auxiliary/eps.hpp b/sprout/weed/parser/auxiliary/eps.hpp index 35bc0472..956895de 100644 --- a/sprout/weed/parser/auxiliary/eps.hpp +++ b/sprout/weed/parser/auxiliary/eps.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -17,15 +18,13 @@ namespace sprout { { public: template - struct attribute { - public: - typedef sprout::weed::unused type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; public: template SPROUT_CONSTEXPR typename result::type operator()( diff --git a/sprout/weed/parser/char/char.hpp b/sprout/weed/parser/char/char.hpp index eae24cec..b825ea33 100644 --- a/sprout/weed/parser/char/char.hpp +++ b/sprout/weed/parser/char/char.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -22,15 +23,13 @@ namespace sprout { { public: template - struct attribute { - public: - typedef sprout::weed::unused type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: T t_; public: @@ -81,15 +80,13 @@ namespace sprout { { public: template - struct attribute { - public: - typedef typename std::iterator_traits::value_type type; - }; + struct attribute + : public sprout::identity::value_type> + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: T t_; public: @@ -122,15 +119,13 @@ namespace sprout { { public: template - struct attribute { - public: - typedef typename std::iterator_traits::value_type type; - }; + struct attribute + : public sprout::identity::value_type> + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; public: template SPROUT_CONSTEXPR typename result::type operator()( diff --git a/sprout/weed/parser/char/char_class.hpp b/sprout/weed/parser/char/char_class.hpp index e12ac4a1..af19f1a9 100644 --- a/sprout/weed/parser/char/char_class.hpp +++ b/sprout/weed/parser/char/char_class.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -18,19 +19,17 @@ namespace sprout { { \ public: \ template \ - struct attribute { \ - public: \ - typedef typename std::conditional< \ + struct attribute \ + : public std::conditional< \ Nil, \ sprout::weed::unused, \ typename std::iterator_traits::value_type \ - >::type type; \ - }; \ + > \ + {}; \ template \ - struct result { \ - public: \ - typedef sprout::weed::parser_result::type> type; \ - }; \ + struct result \ + : public sprout::identity::type> > \ + {}; \ public: \ template \ SPROUT_CONSTEXPR typename result::type operator()( \ diff --git a/sprout/weed/parser/directive/as_array.hpp b/sprout/weed/parser/directive/as_array.hpp index 84171859..9fa705e5 100644 --- a/sprout/weed/parser/directive/as_array.hpp +++ b/sprout/weed/parser/directive/as_array.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -32,10 +33,9 @@ namespace sprout { typedef sprout::array type; }; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: typedef typename sprout::weed::traits::terminal_or_expr_of::type expr_type; private: diff --git a/sprout/weed/parser/directive/as_tuple.hpp b/sprout/weed/parser/directive/as_tuple.hpp index 7c610350..d244604d 100644 --- a/sprout/weed/parser/directive/as_tuple.hpp +++ b/sprout/weed/parser/directive/as_tuple.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -32,10 +33,9 @@ namespace sprout { typedef sprout::tuples::tuple type; }; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: typedef typename sprout::weed::traits::terminal_or_expr_of::type expr_type; private: diff --git a/sprout/weed/parser/directive/omit.hpp b/sprout/weed/parser/directive/omit.hpp index 945f273c..56690daa 100644 --- a/sprout/weed/parser/directive/omit.hpp +++ b/sprout/weed/parser/directive/omit.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -22,15 +23,13 @@ namespace sprout { { public: template - struct attribute { - public: - typedef sprout::weed::unused type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: typedef typename sprout::weed::traits::terminal_or_expr_of::type expr_type; private: diff --git a/sprout/weed/parser/directive/repeat.hpp b/sprout/weed/parser/directive/repeat.hpp index 5f1743a3..b83ec8c1 100644 --- a/sprout/weed/parser/directive/repeat.hpp +++ b/sprout/weed/parser/directive/repeat.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -142,18 +143,16 @@ namespace sprout { }; public: template - struct attribute { - public: - typedef typename sprout::weed::attr_cnv::result_of::times< + struct attribute + : public sprout::weed::attr_cnv::result_of::times< sprout::weed::traits::limit_of::value, typename sprout::weed::traits::attribute_of::type - >::type type; - }; + > + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: typedef typename sprout::weed::traits::terminal_or_expr_of::type expr_type; private: diff --git a/sprout/weed/parser/directive/replace.hpp b/sprout/weed/parser/directive/replace.hpp index 8e13ff23..08381641 100644 --- a/sprout/weed/parser/directive/replace.hpp +++ b/sprout/weed/parser/directive/replace.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -23,15 +24,13 @@ namespace sprout { public: typedef T value_type; template - struct attribute { - public: - typedef value_type type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: typedef typename sprout::weed::traits::terminal_or_expr_of::type expr_type; private: diff --git a/sprout/weed/parser/lim.hpp b/sprout/weed/parser/lim.hpp index 718367b2..81a7dc4a 100644 --- a/sprout/weed/parser/lim.hpp +++ b/sprout/weed/parser/lim.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -25,15 +26,13 @@ namespace sprout { SPROUT_STATIC_CONSTEXPR std::size_t limit = Limit; public: template - struct attribute { - public: - typedef typename sprout::weed::traits::attribute_of::type type; - }; + struct attribute + : public sprout::weed::traits::attribute_of + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: typedef typename sprout::weed::traits::terminal_or_expr_of::type expr_type; private: diff --git a/sprout/weed/parser/numeric/int_p.hpp b/sprout/weed/parser/numeric/int_p.hpp index d460b08d..56d7f759 100644 --- a/sprout/weed/parser/numeric/int_p.hpp +++ b/sprout/weed/parser/numeric/int_p.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -32,15 +33,13 @@ namespace sprout { ; public: template - struct attribute { - public: - typedef IntType type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: template SPROUT_CONSTEXPR typename result::type make_result( diff --git a/sprout/weed/parser/numeric/uint_p.hpp b/sprout/weed/parser/numeric/uint_p.hpp index e3296521..1bc19321 100644 --- a/sprout/weed/parser/numeric/uint_p.hpp +++ b/sprout/weed/parser/numeric/uint_p.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -32,15 +33,13 @@ namespace sprout { ; public: template - struct attribute { - public: - typedef UIntType type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: template SPROUT_CONSTEXPR typename result::type make_result( diff --git a/sprout/weed/parser/string/string.hpp b/sprout/weed/parser/string/string.hpp index 270fd5b0..faf20225 100644 --- a/sprout/weed/parser/string/string.hpp +++ b/sprout/weed/parser/string/string.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -27,15 +28,13 @@ namespace sprout { { public: template - struct attribute { - public: - typedef sprout::weed::unused type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: T t_; public: @@ -102,15 +101,13 @@ namespace sprout { { public: template - struct attribute { - public: - typedef T type; - }; + struct attribute + : public sprout::identity + {}; template - struct result { - public: - typedef sprout::weed::parser_result::type> type; - }; + struct result + : public sprout::identity::type> > + {}; private: T t_; public: diff --git a/sprout/weed/traits/expr/expr_of.hpp b/sprout/weed/traits/expr/expr_of.hpp index 0f183103..bad3daa9 100644 --- a/sprout/weed/traits/expr/expr_of.hpp +++ b/sprout/weed/traits/expr/expr_of.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -14,15 +15,16 @@ namespace sprout { // expr_of // template - struct expr_of { - public: - typedef sprout::weed::expr< - Tag, - typename sprout::weed::traits::terminal_or_expr_of< - typename sprout::remove_shallow_cvref::type - >::type... - > type; - }; + struct expr_of + : public sprout::identity< + sprout::weed::expr< + Tag, + typename sprout::weed::traits::terminal_or_expr_of< + typename sprout::remove_shallow_cvref::type + >::type... + > + > + {}; } // namespace traits } // namespace weed } // namespace sprout diff --git a/sprout/weed/traits/expr/tag_of.hpp b/sprout/weed/traits/expr/tag_of.hpp index fd88d7c3..5f809830 100644 --- a/sprout/weed/traits/expr/tag_of.hpp +++ b/sprout/weed/traits/expr/tag_of.hpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace sprout { @@ -23,10 +24,9 @@ namespace sprout { typename std::enable_if< sprout::weed::traits::is_expr::value >::type - > { - public: - typedef typename Expr::expr_tag type; - }; + > + : public sprout::identity + {}; } // namespace traits } // namespace weed } // namespace sprout diff --git a/sprout/weed/traits/expr/terminal_of.hpp b/sprout/weed/traits/expr/terminal_of.hpp index fdd72f57..a4a630d7 100644 --- a/sprout/weed/traits/expr/terminal_of.hpp +++ b/sprout/weed/traits/expr/terminal_of.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -25,13 +26,14 @@ namespace sprout { typename sprout::remove_shallow_cvref::type >::value >::type - > { - public: - typedef sprout::weed::expr< - sprout::weed::tag::terminal, - typename sprout::remove_shallow_cvref::type - > type; - }; + > + : public sprout::identity< + sprout::weed::expr< + sprout::weed::tag::terminal, + typename sprout::remove_shallow_cvref::type + > + > + {}; template struct terminal_of< Arg, @@ -40,15 +42,16 @@ namespace sprout { typename sprout::remove_shallow_cvref::type >::value >::type - > { - public: - typedef sprout::weed::expr< - sprout::weed::tag::terminal, - typename sprout::weed::detail::c_str_as_string< - typename sprout::remove_shallow_cvref::type - >::type - > type; - }; + > + : public sprout::identity< + sprout::weed::expr< + sprout::weed::tag::terminal, + typename sprout::weed::detail::c_str_as_string< + typename sprout::remove_shallow_cvref::type + >::type + > + > + {}; } // namespace traits } // namespace weed } // namespace sprout diff --git a/sprout/weed/traits/expr/terminal_or_expr_of.hpp b/sprout/weed/traits/expr/terminal_or_expr_of.hpp index 4219dbfc..9470c998 100644 --- a/sprout/weed/traits/expr/terminal_or_expr_of.hpp +++ b/sprout/weed/traits/expr/terminal_or_expr_of.hpp @@ -14,16 +14,15 @@ namespace sprout { // terminal_or_expr_of // template - struct terminal_or_expr_of { - public: - typedef typename std::conditional< + struct terminal_or_expr_of + : public std::conditional< sprout::weed::traits::is_expr< typename sprout::remove_shallow_cvref::type >::value, - typename sprout::remove_shallow_cvref::type, - typename sprout::weed::traits::terminal_of::type - >::type type; - }; + sprout::remove_shallow_cvref, + sprout::weed::traits::terminal_of + >::type + {}; } // namespace traits } // namespace weed } // namespace sprout diff --git a/sprout/weed/traits/parser/attribute_of.hpp b/sprout/weed/traits/parser/attribute_of.hpp index f6b22caa..e8db6ad1 100644 --- a/sprout/weed/traits/parser/attribute_of.hpp +++ b/sprout/weed/traits/parser/attribute_of.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -37,10 +38,9 @@ namespace sprout { && !sprout::weed::traits::is_c_str::value && !sprout::weed::traits::is_string::value >::type - > { - public: - typedef typename T::template attribute::type type; - }; + > + : public T::template attribute + {}; template struct attribute_of< T, @@ -49,10 +49,9 @@ namespace sprout { typename std::enable_if< sprout::weed::traits::is_expr::value >::type - > { - public: - typedef typename Context::template eval::attribute_type type; - }; + > + : public sprout::identity::attribute_type> + {}; template struct attribute_of< T, diff --git a/sprout/weed/traits/parser/is_parser.hpp b/sprout/weed/traits/parser/is_parser.hpp index 39205590..6854f0b4 100644 --- a/sprout/weed/traits/parser/is_parser.hpp +++ b/sprout/weed/traits/parser/is_parser.hpp @@ -52,6 +52,7 @@ namespace sprout { T, typename std::enable_if< sprout::weed::traits::is_c_str::value + && !std::is_const::value >::type > : public std::true_type @@ -61,7 +62,6 @@ namespace sprout { T, typename std::enable_if< std::is_const::value - && !std::is_array::value >::type > : public sprout::weed::traits::is_parser<