mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
change generator_access_traits adapt
This commit is contained in:
parent
7f137c0a83
commit
2fe34cc922
4 changed files with 117 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/iterator/const_reference_cast.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
|
||||
#include <sprout/utility/as_const.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
|
@ -98,6 +99,25 @@ namespace sprout {
|
|||
std::is_lvalue_reference<Gen>::value && !std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::is_substitutable_const_generated_value<Gen>::value
|
||||
&& !sprout::detail::has_mem_generated_value<Gen>::value
|
||||
&& sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(*std::declval<Gen&>())
|
||||
get_generated_value(Gen& gen)
|
||||
SPROUT_NOEXCEPT_IF_EXPR(*std::declval<Gen&>())
|
||||
{
|
||||
return *gen;
|
||||
}
|
||||
};
|
||||
template<typename Gen>
|
||||
struct get_generated_value_impl<
|
||||
Gen,
|
||||
typename std::enable_if<
|
||||
std::is_lvalue_reference<Gen>::value && !std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::is_substitutable_const_generated_value<Gen>::value
|
||||
&& !sprout::detail::has_mem_generated_value<Gen>::value
|
||||
&& !sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
|
@ -150,6 +170,25 @@ namespace sprout {
|
|||
std::is_rvalue_reference<Gen>::value && !std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::is_substitutable_const_generated_value<Gen>::value
|
||||
&& !sprout::detail::has_mem_generated_value<Gen>::value
|
||||
&& sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(*std::declval<Gen&&>())
|
||||
get_generated_value(Gen&& gen)
|
||||
SPROUT_NOEXCEPT_IF_EXPR(*std::declval<Gen&&>())
|
||||
{
|
||||
return *sprout::move(gen);
|
||||
}
|
||||
};
|
||||
template<typename Gen>
|
||||
struct get_generated_value_impl<
|
||||
Gen,
|
||||
typename std::enable_if<
|
||||
std::is_rvalue_reference<Gen>::value && !std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::is_substitutable_const_generated_value<Gen>::value
|
||||
&& !sprout::detail::has_mem_generated_value<Gen>::value
|
||||
&& !sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
|
@ -183,6 +222,24 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
std::is_reference<Gen>::value && std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::has_mem_generated_value<Gen const>::value
|
||||
&& sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(*std::declval<Gen const&>())
|
||||
get_generated_value(Gen const& gen)
|
||||
SPROUT_NOEXCEPT_IF_EXPR(*std::declval<Gen const&>())
|
||||
{
|
||||
return *gen;
|
||||
}
|
||||
};
|
||||
template<typename Gen>
|
||||
struct get_generated_value_impl<
|
||||
Gen,
|
||||
typename std::enable_if<
|
||||
std::is_reference<Gen>::value && std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::has_mem_generated_value<Gen const>::value
|
||||
&& !sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/iterator/const_reference_cast.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
|
||||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/utility/as_const.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
|
@ -98,6 +100,25 @@ namespace sprout {
|
|||
std::is_lvalue_reference<Gen>::value && !std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::is_substitutable_const_next_generator<Gen>::value
|
||||
&& !sprout::detail::has_mem_next_generator<Gen>::value
|
||||
&& !sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(sprout::next(std::declval<Gen&>()))
|
||||
get_next_generator(Gen& gen)
|
||||
SPROUT_NOEXCEPT_IF_EXPR(sprout::next(std::declval<Gen&>()))
|
||||
{
|
||||
return sprout::next(gen);
|
||||
}
|
||||
};
|
||||
template<typename Gen>
|
||||
struct get_next_generator_impl<
|
||||
Gen,
|
||||
typename std::enable_if<
|
||||
std::is_lvalue_reference<Gen>::value && !std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::is_substitutable_const_next_generator<Gen>::value
|
||||
&& !sprout::detail::has_mem_next_generator<Gen>::value
|
||||
&& sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
|
@ -150,6 +171,25 @@ namespace sprout {
|
|||
std::is_rvalue_reference<Gen>::value && !std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::is_substitutable_const_next_generator<Gen>::value
|
||||
&& !sprout::detail::has_mem_next_generator<Gen>::value
|
||||
&& sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(sprout::next(std::declval<Gen&&>()))
|
||||
get_next_generator(Gen&& gen)
|
||||
SPROUT_NOEXCEPT_IF_EXPR(sprout::next(std::declval<Gen&&>()))
|
||||
{
|
||||
return sprout::next(sprout::move(gen));
|
||||
}
|
||||
};
|
||||
template<typename Gen>
|
||||
struct get_next_generator_impl<
|
||||
Gen,
|
||||
typename std::enable_if<
|
||||
std::is_rvalue_reference<Gen>::value && !std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::is_substitutable_const_next_generator<Gen>::value
|
||||
&& !sprout::detail::has_mem_next_generator<Gen>::value
|
||||
&& !sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
|
@ -183,6 +223,24 @@ namespace sprout {
|
|||
typename std::enable_if<
|
||||
std::is_reference<Gen>::value && std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::has_mem_next_generator<Gen const>::value
|
||||
&& sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(sprout::next(std::declval<Gen const&>()))
|
||||
get_next_generator(Gen const& gen)
|
||||
SPROUT_NOEXCEPT_IF_EXPR(sprout::next(std::declval<Gen const&>()))
|
||||
{
|
||||
return sprout::next(gen);
|
||||
}
|
||||
};
|
||||
template<typename Gen>
|
||||
struct get_next_generator_impl<
|
||||
Gen,
|
||||
typename std::enable_if<
|
||||
std::is_reference<Gen>::value && std::is_const<typename std::remove_reference<Gen>::type>::value
|
||||
&& !sprout::detail::has_mem_next_generator<Gen const>::value
|
||||
&& !sprout::is_input_iterator<Gen>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace sprout {
|
|||
// && callable sprout::as_const(t).generated_value()
|
||||
// -> sprout::const_reference_cast<decltype(std::declval<T&>().generated_value())>(sprout::as_const(cont).generated_value())
|
||||
// otherwise, callable t.generated_value() -> t.generated_value()
|
||||
// otherwise, T is InputIterator -> *t
|
||||
// otherwise -> sprout::tuples::get<0>(t)
|
||||
//
|
||||
template<typename T>
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace sprout {
|
|||
// && callable sprout::as_const(t).next_generator()
|
||||
// -> sprout::const_reference_cast<decltype(std::declval<T&>().next_generator())>(sprout::as_const(cont).next_generator())
|
||||
// otherwise, callable t.next_generator() -> t.next_generator()
|
||||
// otherwise, T is InputIterator -> sprout::next(t)
|
||||
// otherwise -> sprout::tuples::get<0>(t)
|
||||
//
|
||||
template<typename T>
|
||||
|
|
Loading…
Reference in a new issue