1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00

add Sprout.Weed ->* Attribute-conversion

This commit is contained in:
bolero-MURAKAMI 2012-05-31 22:28:58 +09:00
parent fa3851227e
commit 3a968fa5ac
35 changed files with 369 additions and 112 deletions

View file

@ -308,4 +308,6 @@ namespace std {
};
} // namespace std
#include <sprout/tuple/array.hpp>
#endif // #ifndef SPROUT_ARRAY_HPP

View file

@ -2,6 +2,11 @@
#define SPROUT_CMATH_HPP
#include <sprout/config.hpp>
#include <sprout/math/functions.hpp>
#include <sprout/math/classifications.hpp>
#include <sprout/math/trigonometric.hpp>
#include <sprout/math/hyperbolic.hpp>
#include <sprout/math/exponential.hpp>
#include <sprout/math/power.hpp>
#include <sprout/math/operations.hpp>
#endif // #ifndef SPROUT_CMATH_HPP

View file

@ -8,6 +8,7 @@
#include <sprout/math/exponential.hpp>
#include <sprout/math/power.hpp>
#include <sprout/math/operations.hpp>
#include <sprout/math/common_factor.hpp>
#include <sprout/math/factorial.hpp>
#include <sprout/math/bernoulli.hpp>

View file

@ -245,4 +245,6 @@ namespace std {
{};
} // namespace std
#include <sprout/tuple/pit.hpp>
#endif // #ifndef SPROUT_PIT_HPP

View file

@ -15,5 +15,6 @@
#include <sprout/string/type_traits.hpp>
#include <sprout/string/alias.hpp>
#include <sprout/string/shrink.hpp>
#include <sprout/tuple/string.hpp>
#endif // #ifndef SPROUT_STRING_HPP

View file

@ -867,4 +867,6 @@ namespace std {
{};
} // namespace std
#include <sprout/tuple/sub_array.hpp>
#endif // #ifndef SPROUT_SUB_ARRAY_HPP

View file

@ -4,7 +4,8 @@
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/tuple/traits.hpp>
#include <sprout/container/metafunctions.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/tuple/metafunctions.hpp>
#include <sprout/tuple/functions.hpp>
#include <sprout/tuple/fused.hpp>
#endif // #ifndef SPROUT_TUPLE_HPP

View file

@ -2,10 +2,8 @@
#define SPROUT_TUPLE_ARRAY_HPP
#include <cstddef>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/array.hpp>
namespace sprout {
@ -14,22 +12,25 @@ namespace sprout {
// get
//
template<std::size_t I, typename T, std::size_t N>
T& get(sprout::array<T, N>& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR T&
get(sprout::array<T, N>& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N>
SPROUT_CONSTEXPR T const& get(sprout::array<T, N> const& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR T const&
get(sprout::array<T, N> const& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N>
T&& get(sprout::array<T, N>&& t) SPROUT_NOEXCEPT {
return std::move(sprout::tuples::get<I>(t));
inline SPROUT_CONSTEXPR T&&
get(sprout::array<T, N>&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples
using sprout::tuples::get;
} // namespace sprout
#endif // #ifndef SPROUT_TUPLE_TUPLE_COMPARISON_HPP
#endif // #ifndef SPROUT_TUPLE_ARRAY_HPP

67
sprout/tuple/fused.hpp Normal file
View file

@ -0,0 +1,67 @@
#ifndef SPROUT_TUPLE_FUSED_HPP
#define SPROUT_TUPLE_FUSED_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
namespace tuples {
//
// fused
//
template<typename F>
class fused {
public:
typedef F functor_type;
private:
functor_type f_;
private:
template<typename Tuple, sprout::index_t... Indexes>
SPROUT_CONSTEXPR auto
call(Tuple&& t, sprout::index_tuple<Indexes...>) const
-> decltype(f_(sprout::tuples::get<Indexes>(sprout::forward<Tuple>(t))...))
{
return f_(sprout::tuples::get<Indexes>(sprout::forward<Tuple>(t))...);
}
public:
fused() = default;
fused(fused const&) = default;
explicit SPROUT_CONSTEXPR fused(F f)
: f_(f)
{}
SPROUT_CONSTEXPR functor_type functor() const {
return f_;
}
template<typename Tuple>
SPROUT_CONSTEXPR auto
operator()(Tuple&& t) const
-> decltype(this->call(
sprout::forward<Tuple>(t),
sprout::index_range<0, sprout::tuples::tuple_size<typename std::decay<Tuple>::type>::value>::make()
))
{
return call(
sprout::forward<Tuple>(t),
sprout::index_range<0, sprout::tuples::tuple_size<typename std::decay<Tuple>::type>::value>::make()
);
}
};
//
// make_fused
//
template<typename F>
inline SPROUT_CONSTEXPR sprout::tuples::fused<F>
make_fused(F const& f) {
return sprout::tuples::fused<F>(f);
}
} // namespace tuples
using sprout::tuples::fused;
using sprout::tuples::make_fused;
} // namespace sprout
#endif // #ifndef SPROUT_TUPLE_FUSED_HPP

View file

@ -2,10 +2,9 @@
#define SPROUT_TUPLE_PIT_HPP
#include <cstddef>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/pit.hpp>
namespace sprout {
@ -14,27 +13,23 @@ namespace sprout {
// get
//
template<std::size_t I, typename Container>
typename sprout::container_traits<sprout::pit<Container> >::value_type& get(
sprout::pit<Container>& t
) SPROUT_NOEXCEPT
{
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::pit<Container> >::value_type&
get(sprout::pit<Container>& t) SPROUT_NOEXCEPT {
static_assert(I < sprout::container_traits<sprout::pit<Container> >::static_size, "get: index out of range");
return t[I];
}
template<std::size_t I, typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<sprout::pit<Container> >::value_type const& get(
sprout::pit<Container> const& t
) SPROUT_NOEXCEPT
{
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::pit<Container> >::value_type const&
get(sprout::pit<Container> const& t) SPROUT_NOEXCEPT {
static_assert(I < sprout::container_traits<sprout::pit<Container> >::static_size, "get: index out of range");
return t[I];
}
template<std::size_t I, typename Container>
typename sprout::container_traits<sprout::pit<Container> >::value_type&& get(
sprout::pit<Container>&& t
) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::move(sprout::tuples::get<I>(t))))
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::pit<Container> >::value_type&&
get(sprout::pit<Container>&& t)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::move(sprout::tuples::get<I>(t))))
{
return std::move(sprout::tuples::get<I>(t));
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples

View file

@ -4,7 +4,7 @@
#include <cstddef>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/utility/move.hpp>
#include <sscrisk/cel/array.hpp>
namespace sprout {
@ -13,18 +13,21 @@ namespace sprout {
// get
//
template<std::size_t I, typename T, std::size_t N>
T& get(sscrisk::cel::array<T, N>& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR T&
get(sscrisk::cel::array<T, N>& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N>
SPROUT_CONSTEXPR T const& get(sscrisk::cel::array<T, N> const& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR T const&
get(sscrisk::cel::array<T, N> const& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N>
T&& get(sscrisk::cel::array<T, N>&& t) SPROUT_NOEXCEPT {
return std::move(sprout::tuples::get<I>(t));
inline SPROUT_CONSTEXPR T&&
get(sscrisk::cel::array<T, N>&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples

View file

@ -3,9 +3,10 @@
#include <cstddef>
#include <type_traits>
#include <sscrisk/cel/utility.hpp>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sscrisk/cel/utility.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
namespace tuples {
@ -48,10 +49,10 @@ namespace sprout {
template<typename T1, typename T2>
struct get_impl<0, sscrisk::cel::pair<T1, T2> > {
public:
T1& operator()(sscrisk::cel::pair<T1, T2>& t) const {
SPROUT_CONSTEXPR T1& operator()(sscrisk::cel::pair<T1, T2>& t) const {
return t.first;
}
T1 const& operator()(sscrisk::cel::pair<T1, T2> const& t) const {
SPROUT_CONSTEXPR T1 const& operator()(sscrisk::cel::pair<T1, T2> const& t) const {
return t.first;
}
};
@ -59,36 +60,30 @@ namespace sprout {
struct get_impl<1, sscrisk::cel::pair<T1, T2> > {
public:
public:
T2& operator()(sscrisk::cel::pair<T1, T2>& t) const {
SPROUT_CONSTEXPR T2& operator()(sscrisk::cel::pair<T1, T2>& t) const {
return t.second;
}
T2 const& operator()(sscrisk::cel::pair<T1, T2> const& t) const {
SPROUT_CONSTEXPR T2 const& operator()(sscrisk::cel::pair<T1, T2> const& t) const {
return t.second;
}
};
} // namespace detail
template<std::size_t I, typename T1, typename T2>
typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type& get(
sscrisk::cel::pair<T1, T2>& t
) SPROUT_NOEXCEPT
{
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&
get(sscrisk::cel::pair<T1, T2>& t) SPROUT_NOEXCEPT {
static_assert(I < 2, "get: index out of range");
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
}
template<std::size_t I, typename T1, typename T2>
SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type const& get(
sscrisk::cel::pair<T1, T2> const& t
) SPROUT_NOEXCEPT
{
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type const&
get(sscrisk::cel::pair<T1, T2> const& t) SPROUT_NOEXCEPT {
static_assert(I < 2, "get: index out of range");
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
}
template<std::size_t I, typename T1, typename T2>
typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&& get(
sscrisk::cel::pair<T1, T2>&& t
) SPROUT_NOEXCEPT
{
return std::move(sprout::tuples::get<I>(t));
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&&
get(sscrisk::cel::pair<T1, T2>&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples

View file

@ -2,10 +2,9 @@
#define SPROUT_TUPLE_STRING_HPP
#include <cstddef>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/string.hpp>
namespace sprout {
@ -14,18 +13,21 @@ namespace sprout {
// get
//
template<std::size_t I, typename T, std::size_t N, typename Traits>
T& get(sprout::basic_string<T, N, Traits>& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR T&
get(sprout::basic_string<T, N, Traits>& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N, typename Traits>
SPROUT_CONSTEXPR T const& get(sprout::basic_string<T, N, Traits> const& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR T const&
get(sprout::basic_string<T, N, Traits> const& t) SPROUT_NOEXCEPT {
static_assert(I < N, "get: index out of range");
return t[I];
}
template<std::size_t I, typename T, std::size_t N, typename Traits>
T&& get(sprout::basic_string<T, N, Traits>&& t) SPROUT_NOEXCEPT {
return std::move(sprout::tuples::get<I>(t));
inline SPROUT_CONSTEXPR T&&
get(sprout::basic_string<T, N, Traits>&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples

View file

@ -2,12 +2,11 @@
#define SPROUT_TUPLE_SUB_ARRAY_HPP
#include <cstddef>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/sub_array.hpp>
namespace sprout {
@ -16,27 +15,27 @@ namespace sprout {
// get
//
template<std::size_t I, typename Container>
typename sprout::container_traits<sprout::sub_array<Container> >::value_type& get(
sprout::sub_array<Container>& t
) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(*sprout::next(sprout::internal_begin(t), I)))
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::sub_array<Container> >::value_type&
get(sprout::sub_array<Container>& t)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(*sprout::next(sprout::internal_begin(t), I)))
{
static_assert(I < sprout::container_traits<sprout::sub_array<Container> >::static_size, "get: index out of range");
return *sprout::next(sprout::internal_begin(t), I);
}
template<std::size_t I, typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<sprout::sub_array<Container> >::value_type const& get(
sprout::sub_array<Container> const& t
) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(*sprout::next(sprout::internal_begin(t), I)))
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::sub_array<Container> >::value_type const&
get(sprout::sub_array<Container> const& t)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(*sprout::next(sprout::internal_begin(t), I)))
{
static_assert(I < sprout::container_traits<sprout::sub_array<Container> >::static_size, "get: index out of range");
return *sprout::next(sprout::internal_begin(t), I);
}
template<std::size_t I, typename Container>
typename sprout::container_traits<sprout::sub_array<Container> >::value_type&& get(
sprout::sub_array<Container>&& t
) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::move(sprout::tuples::get<I>(t))))
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::sub_array<Container> >::value_type&&
get(sprout::sub_array<Container>&& t)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::move(sprout::tuples::get<I>(t))))
{
return std::move(sprout::tuples::get<I>(t));
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples

View file

@ -501,9 +501,8 @@ namespace sprout {
// get
//
template<std::size_t I, typename T>
SPROUT_CONSTEXPR auto get(
T&& t
) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::get<I>(sprout::forward<T>(t))))
SPROUT_CONSTEXPR auto
get(T&& t) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::get<I>(sprout::forward<T>(t))))
-> decltype(std::get<I>(sprout::forward<T>(t)))
{
return std::get<I>(sprout::forward<T>(t));
@ -513,41 +512,31 @@ namespace sprout {
//
namespace detail {
template<std::size_t I, typename Head, typename... Tail>
SPROUT_CONSTEXPR typename std::add_lvalue_reference<Head>::type get_helper(
sprout::tuples::detail::tuple_impl<I, Head, Tail...>& t
) SPROUT_NOEXCEPT
{
SPROUT_CONSTEXPR typename std::add_lvalue_reference<Head>::type
get_helper(sprout::tuples::detail::tuple_impl<I, Head, Tail...>& t) SPROUT_NOEXCEPT {
return sprout::tuples::detail::tuple_impl<I, Head, Tail...>::head(t);
}
template<std::size_t I, typename Head, typename... Tail>
SPROUT_CONSTEXPR typename std::add_lvalue_reference<typename std::add_const<Head>::type>::type get_helper(
sprout::tuples::detail::tuple_impl<I, Head, Tail...> const& t
) SPROUT_NOEXCEPT
{
SPROUT_CONSTEXPR typename std::add_lvalue_reference<typename std::add_const<Head>::type>::type
get_helper(sprout::tuples::detail::tuple_impl<I, Head, Tail...> const& t) SPROUT_NOEXCEPT {
return sprout::tuples::detail::tuple_impl<I, Head, Tail...>::head(t);
}
} // namespace detail
template<std::size_t I, typename... Types>
SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type& get(
sprout::tuples::tuple<Types...>& t
) SPROUT_NOEXCEPT
{
SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type&
get(sprout::tuples::tuple<Types...>& t) SPROUT_NOEXCEPT {
return sprout::tuples::detail::get_helper<I>(t);
}
template<std::size_t I, typename... Types>
SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type&& get(
sprout::tuples::tuple<Types...>&& t
) SPROUT_NOEXCEPT
{
SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type&&
get(sprout::tuples::tuple<Types...>&& t) SPROUT_NOEXCEPT {
return sprout::forward<typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type&&>(
sprout::tuples::get<I>(t)
);
}
template<std::size_t I, typename... Types>
SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type const& get(
sprout::tuples::tuple<Types...> const& t
) SPROUT_NOEXCEPT
{
SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type const&
get(sprout::tuples::tuple<Types...> const& t) SPROUT_NOEXCEPT {
return sprout::tuples::detail::get_helper<I>(t);
}
} // namespace tuples

View file

@ -2,10 +2,9 @@
#define SPROUT_TUPLE_UUID_HPP
#include <cstddef>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/uuid/uuid.hpp>
namespace sprout {
@ -14,18 +13,21 @@ namespace sprout {
// get
//
template<std::size_t I>
sprout::uuids::uuid::value_type& get(sprout::uuids::uuid& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR sprout::uuids::uuid::value_type&
get(sprout::uuids::uuid& t) SPROUT_NOEXCEPT {
static_assert(I < 16, "get: index out of range");
return t[I];
}
template<std::size_t I>
SPROUT_CONSTEXPR sprout::uuids::uuid::value_type const& get(sprout::uuids::uuid const& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR sprout::uuids::uuid::value_type const&
get(sprout::uuids::uuid const& t) SPROUT_NOEXCEPT {
static_assert(I < 16, "get: index out of range");
return t[I];
}
template<std::size_t I>
sprout::uuids::uuid::value_type&& get(sprout::uuids::uuid&& t) SPROUT_NOEXCEPT {
return std::move(sprout::tuples::get<I>(t));
inline SPROUT_CONSTEXPR sprout::uuids::uuid::value_type&&
get(sprout::uuids::uuid&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples

View file

@ -2,7 +2,6 @@
#define SPROUT_TYPE_TRAITS_ALIASES_HPP
#include <sprout/config.hpp>
#if SPROUT_USE_TEMPLATE_ALIASES
# include <cstddef>
# include <type_traits>

View file

@ -6,6 +6,7 @@
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/functional/ref.hpp>
@ -233,27 +234,21 @@ namespace sprout {
};
} // namespace detail
template<std::size_t I, typename T1, typename T2>
typename sprout::tuples::tuple_element<I, sprout::pair<T1, T2> >::type& get(
sprout::pair<T1, T2>& t
) SPROUT_NOEXCEPT
{
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::pair<T1, T2> >::type&
get(sprout::pair<T1, T2>& t) SPROUT_NOEXCEPT {
static_assert(I < 2, "get: index out of range");
return sprout::tuples::detail::get_impl<I, sprout::pair<T1, T2> >()(t);
}
template<std::size_t I, typename T1, typename T2>
SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::pair<T1, T2> >::type const& get(
sprout::pair<T1, T2> const& t
) SPROUT_NOEXCEPT
{
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::pair<T1, T2> >::type const&
get(sprout::pair<T1, T2> const& t) SPROUT_NOEXCEPT {
static_assert(I < 2, "get: index out of range");
return sprout::tuples::detail::get_impl<I, sprout::pair<T1, T2> >()(t);
}
template<std::size_t I, typename T1, typename T2>
typename sprout::tuples::tuple_element<I, sprout::pair<T1, T2> >::type&& get(
sprout::pair<T1, T2>&& t
) SPROUT_NOEXCEPT
{
return std::move(sprout::tuples::get<I>(t));
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::pair<T1, T2> >::type&&
get(sprout::pair<T1, T2>&& t) SPROUT_NOEXCEPT {
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace tuples

View file

@ -281,4 +281,6 @@ namespace std {
};
} // namespace std
#include <sprout/tuple/uuid.hpp>
#endif // #ifndef SPROUT_UUID_UUID_HPP

View file

@ -7,5 +7,6 @@
#include <sprout/weed/attr_cnv/shift_left.hpp>
#include <sprout/weed/attr_cnv/modulus.hpp>
#include <sprout/weed/attr_cnv/bitwise_or.hpp>
#include <sprout/weed/attr_cnv/mem_ptr.hpp>
#endif // #ifndef SPROUT_WEED_ATTR_CNV_HPP

View file

@ -135,7 +135,7 @@ namespace sprout {
typedef typename sprout::weed::attr_cnv::result_of::bitwise_or<T, U>::type type;
return sprout::make<type>();
}
// unused >> unused -> unused
// unused | unused -> unused
template<typename T, typename U, typename X>
inline SPROUT_CONSTEXPR typename std::enable_if<
sprout::weed::detail::is_both_unused<T, U>::value,

View file

@ -0,0 +1,22 @@
#ifndef SPROUT_WEED_ATTR_CNV_MEM_PTR_HPP
#define SPROUT_WEED_ATTR_CNV_MEM_PTR_HPP
#include <sprout/config.hpp>
#include <sprout/weed/attr_cnv/result_of/mem_ptr.hpp>
namespace sprout {
namespace weed {
namespace attr_cnv {
//
// mem_ptr
//
template<typename T, typename U>
inline SPROUT_CONSTEXPR typename sprout::weed::attr_cnv::result_of::mem_ptr<T, U>::type
mem_ptr(T const& t, U const& u) {
return u(t);
}
} // namespace attr_cnv
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_ATTR_CNV_MEM_PTR_HPP

View file

@ -7,5 +7,6 @@
#include <sprout/weed/attr_cnv/result_of/shift_left.hpp>
#include <sprout/weed/attr_cnv/result_of/modulus.hpp>
#include <sprout/weed/attr_cnv/result_of/bitwise_or.hpp>
#include <sprout/weed/attr_cnv/result_of/mem_ptr.hpp>
#endif // #ifndef SPROUT_WEED_ATTR_CNV_RESULT_OF_HPP

View file

@ -0,0 +1,23 @@
#ifndef SPROUT_WEED_ATTR_CNV_RESULT_OF_MEM_PTR_HPP
#define SPROUT_WEED_ATTR_CNV_RESULT_OF_MEM_PTR_HPP
#include <type_traits>
#include <sprout/config.hpp>
namespace sprout {
namespace weed {
namespace attr_cnv {
namespace result_of {
//
// mem_ptr
//
template<typename T, typename U, typename = void>
struct mem_ptr
: public std::result_of<U(T)>
{};
} // namespace result_of
} // namespace attr_cnv
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_ATTR_CNV_RESULT_OF_MEM_PTR_HPP

View file

@ -11,5 +11,6 @@
#include <sprout/weed/context/parse_context/operator/modulus.hpp>
#include <sprout/weed/context/parse_context/operator/minus.hpp>
#include <sprout/weed/context/parse_context/operator/bitwise_or.hpp>
#include <sprout/weed/context/parse_context/operator/mem_ptr.hpp>
#endif // #ifndef SPROUT_WEED_CONTEXT_PARSE_CONTEXT_OPERATOR_HPP

View file

@ -0,0 +1,81 @@
#ifndef SPROUT_WEED_CONTEXT_PARSE_CONTEXT_TERMINAL_OPERATOR_MEM_PTR_HPP
#define SPROUT_WEED_CONTEXT_PARSE_CONTEXT_TERMINAL_OPERATOR_MEM_PTR_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/weed/eval_result.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/eval.hpp>
#include <sprout/weed/attr_cnv/result_of/mem_ptr.hpp>
#include <sprout/weed/attr_cnv/mem_ptr.hpp>
#include <sprout/weed/traits/expr/tag_of.hpp>
#include <sprout/weed/traits/parser/attribute_of.hpp>
#include <sprout/weed/context/parse_context_fwd.hpp>
namespace sprout {
namespace weed {
//
// parse_context::eval
//
template<typename Iterator>
template<typename Expr>
struct parse_context<Iterator>::eval<
Expr,
typename std::enable_if<
std::is_same<
typename sprout::weed::traits::tag_of<Expr>::type,
sprout::weed::tag::mem_ptr
>::value
>::type
> {
private:
typedef sprout::weed::parse_context<Iterator> context_type;
typedef typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type expr1_type;
typedef typename sprout::tuples::tuple_element<1, typename Expr::args_type>::type expr2_type;
public:
typedef typename sprout::weed::attr_cnv::result_of::mem_ptr<
typename sprout::weed::traits::attribute_of<expr1_type, Iterator, context_type>::type,
typename sprout::tuples::tuple_element<0, typename expr2_type::args_type>::type
>::type attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Result1>
SPROUT_CONSTEXPR result_type call_1(
typename Expr::args_type const& args,
context_type const& ctx,
Result1 const& res
) const
{
return res.success()
? result_type(
true,
res.current(),
sprout::weed::attr_cnv::mem_ptr(
res.attr(), sprout::tuples::get<0>(sprout::tuples::get<1>(args).args())
),
context_type(ctx, res.current())
)
: result_type(false, ctx.begin(), attribute_type(), ctx)
;
}
SPROUT_CONSTEXPR result_type call(
typename Expr::args_type const& args,
context_type const& ctx
) const
{
return call_1(args, ctx, sprout::weed::eval(sprout::tuples::get<0>(args), ctx));
}
public:
SPROUT_CONSTEXPR result_type operator()(
Expr const& expr,
context_type const& ctx
) const
{
return call(expr.args(), ctx);
}
};
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_CONTEXT_PARSE_CONTEXT_TERMINAL_OPERATOR_MEM_PTR_HPP

View file

@ -8,6 +8,7 @@
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/traits/type/is_char_type.hpp>
#include <sprout/weed/traits/type/is_string.hpp>
#include <sprout/weed/traits/parser/is_parser.hpp>
#include <sprout/weed/traits/expr/tag_of.hpp>
#include <sprout/weed/traits/parser/attribute_of.hpp>
#include <sprout/weed/context/parse_context_fwd.hpp>
@ -26,6 +27,9 @@ namespace sprout {
typename sprout::weed::traits::tag_of<Expr>::type,
sprout::weed::tag::terminal
>::value
&& sprout::weed::traits::is_parser<
typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type
>::value
&& !sprout::weed::traits::is_char_type<
typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type
>::value

View file

@ -4,6 +4,9 @@
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/weed/expr/expr_fwd.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/traits/expr/expr_of.hpp>
namespace sprout {
namespace weed {

View file

@ -0,0 +1,16 @@
#ifndef SPROUT_WEED_EXPR_EXPR_FWD_HPP
#define SPROUT_WEED_EXPR_EXPR_FWD_HPP
#include <sprout/config.hpp>
namespace sprout {
namespace weed {
//
// expr
//
template<typename Tag, typename... Args>
class expr;
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_EXPR_EXPR_FWD_HPP

View file

@ -16,6 +16,7 @@ namespace sprout {
struct modulus {};
struct minus {};
struct bitwise_or {};
struct mem_ptr {};
} // namespace tag
} // namespace weed
} // namespace sprout

View file

@ -11,5 +11,6 @@
#include <sprout/weed/operator/modulus.hpp>
#include <sprout/weed/operator/minus.hpp>
#include <sprout/weed/operator/bitwise_or.hpp>
#include <sprout/weed/operator/mem_ptr.hpp>
#endif // #ifndef SPROUT_WEED_OPERATOR_HPP

View file

@ -0,0 +1,40 @@
#ifndef SPROUT_WEED_OPERATOR_MEM_PTR_HPP
#define SPROUT_WEED_OPERATOR_MEM_PTR_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/make_expr.hpp>
#include <sprout/weed/traits/expr/expr_of.hpp>
#include <sprout/weed/traits/parser/is_parser.hpp>
#include <sprout/weed/detail/uncvref.hpp>
namespace sprout {
namespace weed {
//
// operator->*
//
template<
typename Arg1,
typename Arg2,
typename = typename std::enable_if<
sprout::weed::traits::is_parser<
typename sprout::weed::detail::uncvref<Arg1>::type
>::value
>::type
>
inline SPROUT_CONSTEXPR typename sprout::weed::traits::expr_of<
sprout::weed::tag::mem_ptr,
Arg1,
Arg2
>::type operator->*(Arg1&& arg1, Arg2&& arg2) {
return sprout::weed::make_expr<sprout::weed::tag::mem_ptr>(
sprout::forward<Arg1>(arg1),
sprout::forward<Arg2>(arg2)
);
}
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_OPERATOR_MEM_PTR_HPP

View file

@ -3,7 +3,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/expr/expr.hpp>
#include <sprout/weed/expr/expr_fwd.hpp>
#include <sprout/weed/traits/expr/terminal_or_expr_of.hpp>
#include <sprout/weed/detail/uncvref.hpp>

View file

@ -3,7 +3,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/expr/expr.hpp>
#include <sprout/weed/expr/expr_fwd.hpp>
namespace sprout {
namespace weed {

View file

@ -3,7 +3,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/expr/expr.hpp>
#include <sprout/weed/expr/expr_fwd.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/traits/type/is_c_str.hpp>
#include <sprout/weed/detail/uncvref.hpp>