diff --git a/sprout/generator/detail/generated_value.hpp b/sprout/generator/detail/generated_value.hpp index bc10f3bc..cb946f09 100644 --- a/sprout/generator/detail/generated_value.hpp +++ b/sprout/generator/detail/generated_value.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -98,6 +99,25 @@ namespace sprout { std::is_lvalue_reference::value && !std::is_const::type>::value && !sprout::detail::is_substitutable_const_generated_value::value && !sprout::detail::has_mem_generated_value::value + && sprout::is_input_iterator::value + >::type + > { + public: + static SPROUT_CONSTEXPR decltype(*std::declval()) + get_generated_value(Gen& gen) + SPROUT_NOEXCEPT_IF_EXPR(*std::declval()) + { + return *gen; + } + }; + template + struct get_generated_value_impl< + Gen, + typename std::enable_if< + std::is_lvalue_reference::value && !std::is_const::type>::value + && !sprout::detail::is_substitutable_const_generated_value::value + && !sprout::detail::has_mem_generated_value::value + && !sprout::is_input_iterator::value >::type > { public: @@ -150,6 +170,25 @@ namespace sprout { std::is_rvalue_reference::value && !std::is_const::type>::value && !sprout::detail::is_substitutable_const_generated_value::value && !sprout::detail::has_mem_generated_value::value + && sprout::is_input_iterator::value + >::type + > { + public: + static SPROUT_CONSTEXPR decltype(*std::declval()) + get_generated_value(Gen&& gen) + SPROUT_NOEXCEPT_IF_EXPR(*std::declval()) + { + return *sprout::move(gen); + } + }; + template + struct get_generated_value_impl< + Gen, + typename std::enable_if< + std::is_rvalue_reference::value && !std::is_const::type>::value + && !sprout::detail::is_substitutable_const_generated_value::value + && !sprout::detail::has_mem_generated_value::value + && !sprout::is_input_iterator::value >::type > { public: @@ -183,6 +222,24 @@ namespace sprout { typename std::enable_if< std::is_reference::value && std::is_const::type>::value && !sprout::detail::has_mem_generated_value::value + && sprout::is_input_iterator::value + >::type + > { + public: + static SPROUT_CONSTEXPR decltype(*std::declval()) + get_generated_value(Gen const& gen) + SPROUT_NOEXCEPT_IF_EXPR(*std::declval()) + { + return *gen; + } + }; + template + struct get_generated_value_impl< + Gen, + typename std::enable_if< + std::is_reference::value && std::is_const::type>::value + && !sprout::detail::has_mem_generated_value::value + && !sprout::is_input_iterator::value >::type > { public: diff --git a/sprout/generator/detail/next_generator.hpp b/sprout/generator/detail/next_generator.hpp index d1c603be..e9c42794 100644 --- a/sprout/generator/detail/next_generator.hpp +++ b/sprout/generator/detail/next_generator.hpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -98,6 +100,25 @@ namespace sprout { std::is_lvalue_reference::value && !std::is_const::type>::value && !sprout::detail::is_substitutable_const_next_generator::value && !sprout::detail::has_mem_next_generator::value + && !sprout::is_input_iterator::value + >::type + > { + public: + static SPROUT_CONSTEXPR decltype(sprout::next(std::declval())) + get_next_generator(Gen& gen) + SPROUT_NOEXCEPT_IF_EXPR(sprout::next(std::declval())) + { + return sprout::next(gen); + } + }; + template + struct get_next_generator_impl< + Gen, + typename std::enable_if< + std::is_lvalue_reference::value && !std::is_const::type>::value + && !sprout::detail::is_substitutable_const_next_generator::value + && !sprout::detail::has_mem_next_generator::value + && sprout::is_input_iterator::value >::type > { public: @@ -150,6 +171,25 @@ namespace sprout { std::is_rvalue_reference::value && !std::is_const::type>::value && !sprout::detail::is_substitutable_const_next_generator::value && !sprout::detail::has_mem_next_generator::value + && sprout::is_input_iterator::value + >::type + > { + public: + static SPROUT_CONSTEXPR decltype(sprout::next(std::declval())) + get_next_generator(Gen&& gen) + SPROUT_NOEXCEPT_IF_EXPR(sprout::next(std::declval())) + { + return sprout::next(sprout::move(gen)); + } + }; + template + struct get_next_generator_impl< + Gen, + typename std::enable_if< + std::is_rvalue_reference::value && !std::is_const::type>::value + && !sprout::detail::is_substitutable_const_next_generator::value + && !sprout::detail::has_mem_next_generator::value + && !sprout::is_input_iterator::value >::type > { public: @@ -183,6 +223,24 @@ namespace sprout { typename std::enable_if< std::is_reference::value && std::is_const::type>::value && !sprout::detail::has_mem_next_generator::value + && sprout::is_input_iterator::value + >::type + > { + public: + static SPROUT_CONSTEXPR decltype(sprout::next(std::declval())) + get_next_generator(Gen const& gen) + SPROUT_NOEXCEPT_IF_EXPR(sprout::next(std::declval())) + { + return sprout::next(gen); + } + }; + template + struct get_next_generator_impl< + Gen, + typename std::enable_if< + std::is_reference::value && std::is_const::type>::value + && !sprout::detail::has_mem_next_generator::value + && !sprout::is_input_iterator::value >::type > { public: diff --git a/sprout/generator/generated_value.hpp b/sprout/generator/generated_value.hpp index b0848576..e0abea59 100644 --- a/sprout/generator/generated_value.hpp +++ b/sprout/generator/generated_value.hpp @@ -28,6 +28,7 @@ namespace sprout { // && callable sprout::as_const(t).generated_value() // -> sprout::const_reference_cast().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 diff --git a/sprout/generator/next_generator.hpp b/sprout/generator/next_generator.hpp index f53275c8..bb50de83 100644 --- a/sprout/generator/next_generator.hpp +++ b/sprout/generator/next_generator.hpp @@ -28,6 +28,7 @@ namespace sprout { // && callable sprout::as_const(t).next_generator() // -> sprout::const_reference_cast().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