mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-11-14 10:39:05 +00:00
fix weed type_traits
This commit is contained in:
parent
f712788cce
commit
c78e1d0e6d
27 changed files with 279 additions and 306 deletions
|
@ -11,9 +11,9 @@ namespace sprout {
|
|||
struct float_promote1
|
||||
: public std::conditional<
|
||||
std::is_floating_point<T>::value,
|
||||
sprout::identity<T>,
|
||||
sprout::identity<double>
|
||||
>::type
|
||||
T,
|
||||
double
|
||||
>
|
||||
{
|
||||
static_assert(
|
||||
std::is_arithmetic<T>::value,
|
||||
|
@ -25,13 +25,13 @@ namespace sprout {
|
|||
struct float_promote2
|
||||
: public std::conditional<
|
||||
(std::is_same<T, long double>::value || std::is_same<U, long double>::value),
|
||||
sprout::identity<long double>,
|
||||
long double,
|
||||
typename std::conditional<
|
||||
(std::is_same<T, float>::value && std::is_same<U, float>::value),
|
||||
float,
|
||||
double
|
||||
>
|
||||
>::type
|
||||
>::type
|
||||
>
|
||||
{
|
||||
static_assert(
|
||||
std::is_arithmetic<T>::value && std::is_arithmetic<U>::value,
|
||||
|
|
|
@ -40,22 +40,6 @@ namespace sprout {
|
|||
struct is_c_str<char32_t[N]>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<std::size_t N>
|
||||
struct is_c_str<char const[N]>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<std::size_t N>
|
||||
struct is_c_str<wchar_t const[N]>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<std::size_t N>
|
||||
struct is_c_str<char16_t const[N]>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<std::size_t N>
|
||||
struct is_c_str<char32_t const[N]>
|
||||
: public std::true_type
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <sprout/array/array.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/variant/variant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/traits/type/is_char_type.hpp>
|
||||
#include <sprout/weed/detail/is_same_container.hpp>
|
||||
|
@ -36,14 +37,13 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_same_container<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
>
|
||||
: public std::conditional<
|
||||
!(sprout::tuples::tuple_size<T>::value < sprout::tuples::tuple_size<U>::value),
|
||||
T,
|
||||
U
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
// container<V, N> | V -> container<V, N ? N : 1>
|
||||
template<typename T, typename U>
|
||||
struct bitwise_or<
|
||||
|
@ -52,14 +52,13 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_container_and_elem<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
>
|
||||
: public std::conditional<
|
||||
sprout::container_traits<T>::static_size != 0,
|
||||
T,
|
||||
typename sprout::container_transform_traits<T>::template rebind_size<1>::type
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
// V | container<V, N> -> container<V, N ? N : 1>
|
||||
template<typename T, typename U>
|
||||
struct bitwise_or<
|
||||
|
@ -68,14 +67,13 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_elem_and_container<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
>
|
||||
: public std::conditional<
|
||||
sprout::container_traits<T>::static_size != 0,
|
||||
U,
|
||||
typename sprout::container_transform_traits<U>::template rebind_size<1>::type
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
// tuple<Vs...> | tuple<Ws...> -> tuple<max(Vs..., Ws...)>
|
||||
template<typename T, typename U>
|
||||
struct bitwise_or<
|
||||
|
@ -84,14 +82,13 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_both_tuple<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
>
|
||||
: public std::conditional<
|
||||
!(sprout::tuples::tuple_size<T>::value < sprout::tuples::tuple_size<U>::value),
|
||||
T,
|
||||
U
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
// V | V -> V
|
||||
template<typename T, typename U>
|
||||
struct bitwise_or<
|
||||
|
@ -100,10 +97,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_same_elem<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef T type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<T>
|
||||
{};
|
||||
// V | W -> variant<V, W>
|
||||
template<typename T, typename U>
|
||||
struct bitwise_or<
|
||||
|
@ -112,10 +108,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_different_elem<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef sprout::variant<T, U> type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<sprout::variant<T, U> >
|
||||
{};
|
||||
// V | unused -> container<V, 1>
|
||||
template<typename T, typename U>
|
||||
struct bitwise_or<
|
||||
|
@ -124,14 +119,13 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_elem_and_unused<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
>
|
||||
: public std::conditional<
|
||||
sprout::weed::traits::is_char_type<T>::value,
|
||||
sprout::basic_string<T, 1>,
|
||||
sprout::array<T, 1>
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
// unused | V -> container<V, 1>
|
||||
template<typename T, typename U>
|
||||
struct bitwise_or<
|
||||
|
@ -140,14 +134,13 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_unused_and_elem<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
>
|
||||
: public std::conditional<
|
||||
sprout::weed::traits::is_char_type<U>::value,
|
||||
sprout::basic_string<U, 1>,
|
||||
sprout::array<U, 1>
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
// unused | unused -> unused
|
||||
template<typename T, typename U>
|
||||
struct bitwise_or<
|
||||
|
@ -156,10 +149,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_both_unused<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
} // namespace result_of
|
||||
} // namespace attr_cnv
|
||||
} // namespace weed
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/traits/type/is_unused.hpp>
|
||||
|
||||
|
@ -22,10 +23,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::traits::is_unused<T>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
} // namespace result_of
|
||||
} // namespace attr_cnv
|
||||
} // namespace weed
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <sprout/tuple/operation/append_back.hpp>
|
||||
#include <sprout/tuple/operation/push_back.hpp>
|
||||
#include <sprout/tuple/operation/push_front.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/traits/type/is_char_type.hpp>
|
||||
#include <sprout/weed/detail/is_same_container.hpp>
|
||||
|
@ -42,10 +43,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_same_container<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename sprout::fixed::result_of::append_back<T, U>::type type;
|
||||
};
|
||||
>
|
||||
: public sprout::fixed::result_of::append_back<T, U>
|
||||
{};
|
||||
// container<V, N> >> V -> container<V, N + 1>
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -54,10 +54,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_container_and_elem<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename sprout::fixed::result_of::push_back<T, U>::type type;
|
||||
};
|
||||
>
|
||||
: public sprout::fixed::result_of::push_back<T, U>
|
||||
{};
|
||||
// V >> container<V, N> -> container<V, N + 1>
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -66,10 +65,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_elem_and_container<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename sprout::fixed::result_of::push_front<T, U>::type type;
|
||||
};
|
||||
>
|
||||
: public sprout::fixed::result_of::push_front<T, U>
|
||||
{};
|
||||
// tuple<Vs...> >> tuple<Ws...> -> tuple<Vs..., Ws...>
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -78,10 +76,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_both_tuple<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename sprout::tuples::result_of::append_back<T, U>::type type;
|
||||
};
|
||||
>
|
||||
: public sprout::tuples::result_of::append_back<T, U>
|
||||
{};
|
||||
// tuple<Vs...> >> V -> tuple<Vs..., V>
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -90,10 +87,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_tuple_and_elem<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename sprout::tuples::result_of::push_back<T, U>::type type;
|
||||
};
|
||||
>
|
||||
: public sprout::tuples::result_of::push_back<T, U>
|
||||
{};
|
||||
// V >> tuple<Vs...> -> tuple<V, Vs...>
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -102,10 +98,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_elem_and_tuple<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename sprout::tuples::result_of::push_front<T, U>::type type;
|
||||
};
|
||||
>
|
||||
: public sprout::tuples::result_of::push_front<T, U>
|
||||
{};
|
||||
// V >> V -> container<V, 2>
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -114,14 +109,13 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_same_elem<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
>
|
||||
: public std::conditional<
|
||||
sprout::weed::traits::is_char_type<T>::value,
|
||||
sprout::basic_string<T, 2>,
|
||||
sprout::array<T, 2>
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
// V >> W -> tuple<V, W>
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -130,10 +124,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_different_elem<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef sprout::tuples::tuple<T, U> type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<sprout::tuples::tuple<T, U> >
|
||||
{};
|
||||
// V >> unused -> V
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -142,10 +135,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_elem_and_unused<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef T type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<T>
|
||||
{};
|
||||
// unused >> V -> V
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -154,10 +146,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_unused_and_elem<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef U type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<U>
|
||||
{};
|
||||
// unused >> unused -> unused
|
||||
template<typename T, typename U>
|
||||
struct shift_left<
|
||||
|
@ -166,10 +157,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::detail::is_both_unused<T, U>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
} // namespace result_of
|
||||
} // namespace attr_cnv
|
||||
} // namespace weed
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <sprout/string.hpp>
|
||||
#include <sprout/array/array.hpp>
|
||||
#include <sprout/algorithm/string/join.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/traits/type/is_char_type.hpp>
|
||||
#include <sprout/weed/traits/type/is_container.hpp>
|
||||
|
@ -30,12 +31,11 @@ namespace sprout {
|
|||
Limit != std::size_t(-1)
|
||||
&& sprout::weed::traits::is_container<T>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename sprout::algorithm::result_of::join<
|
||||
>
|
||||
: public sprout::algorithm::result_of::join<
|
||||
sprout::array<T, Limit>
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
// times<N>(V) -> container<V, N>
|
||||
template<std::size_t Limit, typename T>
|
||||
struct times<
|
||||
|
@ -46,14 +46,13 @@ namespace sprout {
|
|||
&& !sprout::weed::traits::is_container<T>::value
|
||||
&& !sprout::weed::traits::is_unused<T>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
>
|
||||
: public std::conditional<
|
||||
sprout::weed::traits::is_char_type<T>::value,
|
||||
sprout::basic_string<T, Limit>,
|
||||
sprout::array<T, Limit>
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
// times<N>(unused) -> unused
|
||||
template<std::size_t Limit, typename T>
|
||||
struct times<
|
||||
|
@ -62,10 +61,9 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
sprout::weed::traits::is_unused<T>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
>
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
} // namespace result_of
|
||||
} // namespace attr_cnv
|
||||
} // namespace weed
|
||||
|
|
|
@ -4,17 +4,41 @@
|
|||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/string.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace weed {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
struct c_str_as_string;
|
||||
template<typename T>
|
||||
struct c_str_as_string<T const>
|
||||
: public sprout::weed::detail::c_str_as_string<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct c_str_as_string<T volatile>
|
||||
: public sprout::weed::detail::c_str_as_string<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct c_str_as_string<T const volatile>
|
||||
: public sprout::weed::detail::c_str_as_string<T>
|
||||
{};
|
||||
template<typename T, std::size_t N>
|
||||
struct c_str_as_string<T const[N]> {
|
||||
public:
|
||||
typedef sprout::basic_string<T, N - 1> type;
|
||||
};
|
||||
struct c_str_as_string<T[N]>
|
||||
: public sprout::identity<sprout::basic_string<T, N - 1> >
|
||||
{};
|
||||
template<typename T, std::size_t N>
|
||||
struct c_str_as_string<T const[N]>
|
||||
: public sprout::identity<sprout::basic_string<T, N - 1> >
|
||||
{};
|
||||
template<typename T, std::size_t N>
|
||||
struct c_str_as_string<T volatile[N]>
|
||||
: public sprout::identity<sprout::basic_string<T, N - 1> >
|
||||
{};
|
||||
template<typename T, std::size_t N>
|
||||
struct c_str_as_string<T const volatile[N]>
|
||||
: public sprout::identity<sprout::basic_string<T, N - 1> >
|
||||
{};
|
||||
} // namespace detail
|
||||
} // namespace weed
|
||||
} // namespace sprout
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/parser/parser_base.hpp>
|
||||
|
@ -17,15 +18,13 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
SPROUT_CONSTEXPR typename result<Context, Iterator>::type operator()(
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/parser/parser_base.hpp>
|
||||
|
@ -18,15 +19,13 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
SPROUT_CONSTEXPR typename result<Context, Iterator>::type operator()(
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/parser/parser_base.hpp>
|
||||
|
@ -17,15 +18,13 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
SPROUT_CONSTEXPR typename result<Context, Iterator>::type operator()(
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/parser/parser_base.hpp>
|
||||
|
@ -22,15 +23,13 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
T t_;
|
||||
public:
|
||||
|
@ -81,15 +80,13 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef typename std::iterator_traits<Iterator>::value_type type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<typename std::iterator_traits<Iterator>::value_type>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
T t_;
|
||||
public:
|
||||
|
@ -122,15 +119,13 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef typename std::iterator_traits<Iterator>::value_type type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<typename std::iterator_traits<Iterator>::value_type>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
SPROUT_CONSTEXPR typename result<Context, Iterator>::type operator()(
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/ctype/ascii.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/parser/parser_base.hpp>
|
||||
|
@ -18,19 +19,17 @@ namespace sprout {
|
|||
{ \
|
||||
public: \
|
||||
template<typename Context, typename Iterator> \
|
||||
struct attribute { \
|
||||
public: \
|
||||
typedef typename std::conditional< \
|
||||
struct attribute \
|
||||
: public std::conditional< \
|
||||
Nil, \
|
||||
sprout::weed::unused, \
|
||||
typename std::iterator_traits<Iterator>::value_type \
|
||||
>::type type; \
|
||||
}; \
|
||||
> \
|
||||
{}; \
|
||||
template<typename Context, typename Iterator> \
|
||||
struct result { \
|
||||
public: \
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type; \
|
||||
}; \
|
||||
struct result \
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> > \
|
||||
{}; \
|
||||
public: \
|
||||
template<typename Context, typename Iterator> \
|
||||
SPROUT_CONSTEXPR typename result<Context, Iterator>::type operator()( \
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/array/array.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/expr/make_terminal_or_expr.hpp>
|
||||
#include <sprout/weed/expr/eval.hpp>
|
||||
|
@ -32,10 +33,9 @@ namespace sprout {
|
|||
typedef sprout::array<attr_type, 1> type;
|
||||
};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
typedef typename sprout::weed::traits::terminal_or_expr_of<Parser>::type expr_type;
|
||||
private:
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/expr/make_terminal_or_expr.hpp>
|
||||
#include <sprout/weed/expr/eval.hpp>
|
||||
|
@ -32,10 +33,9 @@ namespace sprout {
|
|||
typedef sprout::tuples::tuple<attr_type> type;
|
||||
};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
typedef typename sprout::weed::traits::terminal_or_expr_of<Parser>::type expr_type;
|
||||
private:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/expr/make_terminal_or_expr.hpp>
|
||||
|
@ -22,15 +23,13 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
typedef typename sprout::weed::traits::terminal_or_expr_of<Parser>::type expr_type;
|
||||
private:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/expr/make_terminal_or_expr.hpp>
|
||||
#include <sprout/weed/expr/eval.hpp>
|
||||
|
@ -142,18 +143,16 @@ namespace sprout {
|
|||
};
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
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<Parser, Iterator, Context>::value,
|
||||
typename sprout::weed::traits::attribute_of<Parser, Iterator, Context>::type
|
||||
>::type type;
|
||||
};
|
||||
>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
typedef typename sprout::weed::traits::terminal_or_expr_of<Parser>::type expr_type;
|
||||
private:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/expr/make_terminal_or_expr.hpp>
|
||||
|
@ -23,15 +24,13 @@ namespace sprout {
|
|||
public:
|
||||
typedef T value_type;
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef value_type type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<value_type>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
typedef typename sprout::weed::traits::terminal_or_expr_of<Parser>::type expr_type;
|
||||
private:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/limited.hpp>
|
||||
#include <sprout/weed/expr/make_terminal_or_expr.hpp>
|
||||
|
@ -25,15 +26,13 @@ namespace sprout {
|
|||
SPROUT_STATIC_CONSTEXPR std::size_t limit = Limit;
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef typename sprout::weed::traits::attribute_of<Parser, Iterator, Context>::type type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::weed::traits::attribute_of<Parser, Iterator, Context>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
typedef typename sprout::weed::traits::terminal_or_expr_of<Parser>::type expr_type;
|
||||
private:
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/integer/integer_digits.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/parser/parser_base.hpp>
|
||||
|
@ -32,15 +33,13 @@ namespace sprout {
|
|||
;
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef IntType type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<IntType>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
template<typename Context, typename Iterator>
|
||||
SPROUT_CONSTEXPR typename result<Context, Iterator>::type make_result(
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/integer/integer_digits.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/parser/parser_base.hpp>
|
||||
|
@ -32,15 +33,13 @@ namespace sprout {
|
|||
;
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef UIntType type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<UIntType>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
template<typename Context, typename Iterator>
|
||||
SPROUT_CONSTEXPR typename result<Context, Iterator>::type make_result(
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <sprout/container/size.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/equal.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser_result.hpp>
|
||||
#include <sprout/weed/parser/parser_base.hpp>
|
||||
|
@ -27,15 +28,13 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef sprout::weed::unused type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<sprout::weed::unused>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
T t_;
|
||||
public:
|
||||
|
@ -102,15 +101,13 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
template<typename Context, typename Iterator>
|
||||
struct attribute {
|
||||
public:
|
||||
typedef T type;
|
||||
};
|
||||
struct attribute
|
||||
: public sprout::identity<T>
|
||||
{};
|
||||
template<typename Context, typename Iterator>
|
||||
struct result {
|
||||
public:
|
||||
typedef sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> type;
|
||||
};
|
||||
struct result
|
||||
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
||||
{};
|
||||
private:
|
||||
T t_;
|
||||
public:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<
|
||||
|
|
Loading…
Reference in a new issue