1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

fix weed type_traits

This commit is contained in:
bolero-MURAKAMI 2013-03-25 12:43:47 +09:00
parent f712788cce
commit c78e1d0e6d
27 changed files with 279 additions and 306 deletions

View file

@ -3,6 +3,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/identity.hpp>
#include <sprout/type_traits/remove_shallow_cvref.hpp>
#include <sprout/weed/expr/expr_fwd.hpp>
#include <sprout/weed/traits/expr/terminal_or_expr_of.hpp>
@ -14,15 +15,16 @@ namespace sprout {
// expr_of
//
template<typename Tag, typename... Args>
struct expr_of {
public:
typedef sprout::weed::expr<
Tag,
typename sprout::weed::traits::terminal_or_expr_of<
typename sprout::remove_shallow_cvref<Args>::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<Args>::type
>::type...
>
>
{};
} // namespace traits
} // namespace weed
} // namespace sprout

View file

@ -3,6 +3,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/identity.hpp>
#include <sprout/weed/traits/expr/is_expr.hpp>
namespace sprout {
@ -23,10 +24,9 @@ namespace sprout {
typename std::enable_if<
sprout::weed::traits::is_expr<Expr>::value
>::type
> {
public:
typedef typename Expr::expr_tag type;
};
>
: public sprout::identity<typename Expr::expr_tag>
{};
} // namespace traits
} // namespace weed
} // namespace sprout

View file

@ -3,6 +3,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/type_traits/identity.hpp>
#include <sprout/type_traits/remove_shallow_cvref.hpp>
#include <sprout/weed/expr/expr_fwd.hpp>
#include <sprout/weed/expr/tag.hpp>
@ -25,13 +26,14 @@ namespace sprout {
typename sprout::remove_shallow_cvref<Arg>::type
>::value
>::type
> {
public:
typedef sprout::weed::expr<
sprout::weed::tag::terminal,
typename sprout::remove_shallow_cvref<Arg>::type
> type;
};
>
: public sprout::identity<
sprout::weed::expr<
sprout::weed::tag::terminal,
typename sprout::remove_shallow_cvref<Arg>::type
>
>
{};
template<typename Arg>
struct terminal_of<
Arg,
@ -40,15 +42,16 @@ namespace sprout {
typename sprout::remove_shallow_cvref<Arg>::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<Arg>::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<Arg>::type
>::type
>
>
{};
} // namespace traits
} // namespace weed
} // namespace sprout

View file

@ -14,16 +14,15 @@ namespace sprout {
// terminal_or_expr_of
//
template<typename Arg>
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<Arg>::type
>::value,
typename sprout::remove_shallow_cvref<Arg>::type,
typename sprout::weed::traits::terminal_of<Arg>::type
>::type type;
};
sprout::remove_shallow_cvref<Arg>,
sprout::weed::traits::terminal_of<Arg>
>::type
{};
} // namespace traits
} // namespace weed
} // namespace sprout

View file

@ -3,6 +3,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/traits/expr/is_expr.hpp>
#include <sprout/weed/unused.hpp>
#include <sprout/weed/expr/expr.hpp>
#include <sprout/weed/expr/tag.hpp>
@ -37,10 +38,9 @@ namespace sprout {
&& !sprout::weed::traits::is_c_str<T>::value
&& !sprout::weed::traits::is_string<T>::value
>::type
> {
public:
typedef typename T::template attribute<Context, Iterator>::type type;
};
>
: public T::template attribute<Context, Iterator>
{};
template<typename T, typename Iterator, typename Context>
struct attribute_of<
T,
@ -49,10 +49,9 @@ namespace sprout {
typename std::enable_if<
sprout::weed::traits::is_expr<T>::value
>::type
> {
public:
typedef typename Context::template eval<T>::attribute_type type;
};
>
: public sprout::identity<typename Context::template eval<T>::attribute_type>
{};
template<typename T, typename Iterator, typename Context>
struct attribute_of<
T,

View file

@ -52,6 +52,7 @@ namespace sprout {
T,
typename std::enable_if<
sprout::weed::traits::is_c_str<T>::value
&& !std::is_const<T>::value
>::type
>
: public std::true_type
@ -61,7 +62,6 @@ namespace sprout {
T,
typename std::enable_if<
std::is_const<T>::value
&& !std::is_array<T>::value
>::type
>
: public sprout::weed::traits::is_parser<