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

sprout/weed.hpp 追加

This commit is contained in:
bolero-MURAKAMI 2011-11-13 17:54:38 +09:00
parent 8103682fdb
commit ecfc2b297a
96 changed files with 5127 additions and 0 deletions

View file

@ -0,0 +1,30 @@
#ifndef SPROUT_WEED_TRAITS_EXPR_EXPR_OF_HPP
#define SPROUT_WEED_TRAITS_EXPR_EXPR_OF_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/expr/expr.hpp>
#include <sprout/weed/traits/expr/terminal_or_expr_of.hpp>
#include <sprout/weed/detail/uncvref.hpp>
namespace sprout {
namespace weed {
namespace traits {
//
// 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::weed::detail::uncvref<Args>::type
>::type...
> type;
};
} // namespace traits
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_TRAITS_EXPR_EXPR_OF_HPP

View file

@ -0,0 +1,30 @@
#ifndef SPROUT_WEED_TRAITS_EXPR_IS_EXPR_HPP
#define SPROUT_WEED_TRAITS_EXPR_IS_EXPR_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/expr/expr.hpp>
namespace sprout {
namespace weed {
namespace traits {
//
// is_expr
//
template<typename T>
struct is_expr
: public std::false_type
{};
template<typename T>
struct is_expr<T const>
: public sprout::weed::traits::is_expr<T>
{};
template<typename Tag, typename... Args>
struct is_expr<sprout::weed::expr<Tag, Args...> >
: public std::true_type
{};
} // namespace traits
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_TRAITS_EXPR_IS_EXPR_HPP

View file

@ -0,0 +1,34 @@
#ifndef SPROUT_WEED_TRAITS_EXPR_TAG_OF_HPP
#define SPROUT_WEED_TRAITS_EXPR_TAG_OF_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/traits/expr/is_expr.hpp>
namespace sprout {
namespace weed {
namespace traits {
//
// tag_of
//
template<typename Expr, typename = void>
struct tag_of;
template<typename Expr>
struct tag_of<Expr const>
: public sprout::weed::traits::tag_of<Expr>
{};
template<typename Expr>
struct tag_of<
Expr,
typename std::enable_if<
sprout::weed::traits::is_expr<Expr>::value
>::type
> {
public:
typedef typename Expr::expr_tag type;
};
} // namespace traits
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_TRAITS_EXPR_TAG_OF_HPP

View file

@ -0,0 +1,56 @@
#ifndef SPROUT_WEED_TRAITS_EXPR_TERMINAL_OF_HPP
#define SPROUT_WEED_TRAITS_EXPR_TERMINAL_OF_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/expr/expr.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/traits/type/is_c_str.hpp>
#include <sprout/weed/detail/uncvref.hpp>
#include <sprout/weed/detail/c_str_as_string.hpp>
namespace sprout {
namespace weed {
namespace traits {
//
// terminal_of
//
template<typename Arg, typename = void>
struct terminal_of;
template<typename Arg>
struct terminal_of<
Arg,
typename std::enable_if<
!sprout::weed::traits::is_c_str<
typename sprout::weed::detail::uncvref<Arg>::type
>::value
>::type
> {
public:
typedef sprout::weed::expr<
sprout::weed::tag::terminal,
typename sprout::weed::detail::uncvref<Arg>::type
> type;
};
template<typename Arg>
struct terminal_of<
Arg,
typename std::enable_if<
sprout::weed::traits::is_c_str<
typename sprout::weed::detail::uncvref<Arg>::type
>::value
>::type
> {
public:
typedef sprout::weed::expr<
sprout::weed::tag::terminal,
typename sprout::weed::detail::c_str_as_string<
typename sprout::weed::detail::uncvref<Arg>::type
>::type
> type;
};
} // namespace traits
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_TRAITS_EXPR_TERMINAL_OF_HPP

View file

@ -0,0 +1,31 @@
#ifndef SPROUT_WEED_TRAITS_EXPR_TERMINAL_OR_EXPR_OF_HPP
#define SPROUT_WEED_TRAITS_EXPR_TERMINAL_OR_EXPR_OF_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/traits/expr/is_expr.hpp>
#include <sprout/weed/traits/expr/terminal_of.hpp>
#include <sprout/weed/detail/uncvref.hpp>
namespace sprout {
namespace weed {
namespace traits {
//
// terminal_or_expr_of
//
template<typename Arg>
struct terminal_or_expr_of {
public:
typedef typename std::conditional<
sprout::weed::traits::is_expr<
typename sprout::weed::detail::uncvref<Arg>::type
>::value,
typename sprout::weed::detail::uncvref<Arg>::type,
typename sprout::weed::traits::terminal_of<Arg>::type
>::type type;
};
} // namespace traits
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_TRAITS_EXPR_TERMINAL_OR_EXPR_OF_HPP