2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2019-01-07 08:47:17 +00:00
|
|
|
Copyright (c) 2011-2019 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2012-09-21 06:43:30 +00:00
|
|
|
#ifndef SPROUT_GENERATOR_NEXT_GENERATOR_HPP
|
|
|
|
#define SPROUT_GENERATOR_NEXT_GENERATOR_HPP
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
#include <type_traits>
|
2013-04-22 04:04:27 +00:00
|
|
|
#include <sprout/config.hpp>
|
2012-09-21 06:43:30 +00:00
|
|
|
#include <sprout/utility/forward.hpp>
|
2013-04-22 04:04:27 +00:00
|
|
|
#include <sprout/generator/generator_access_traits.hpp>
|
2012-09-21 06:43:30 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace generators {
|
|
|
|
//
|
|
|
|
// next_generator
|
|
|
|
//
|
2013-04-22 14:55:30 +00:00
|
|
|
// effect:
|
2016-04-27 06:02:12 +00:00
|
|
|
// sprout::generators::generator_access_traits<T>::get_next_generator(t)
|
2013-04-22 14:55:30 +00:00
|
|
|
// [default]
|
2016-04-14 11:14:49 +00:00
|
|
|
// ADL callable get_next_generator(t) -> get_next_generator(t)
|
|
|
|
// [default]
|
2016-04-27 06:02:12 +00:00
|
|
|
// T is not const
|
|
|
|
// && 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()
|
2016-04-27 23:42:13 +00:00
|
|
|
// otherwise, T is InputIterator -> t
|
2016-04-14 11:14:49 +00:00
|
|
|
// otherwise -> sprout::tuples::get<0>(t)
|
2013-04-22 14:55:30 +00:00
|
|
|
//
|
2012-09-21 06:43:30 +00:00
|
|
|
template<typename T>
|
2016-04-14 11:14:49 +00:00
|
|
|
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<typename std::remove_reference<T>::type>::get_next_generator(std::declval<T>()))
|
2012-09-21 06:43:30 +00:00
|
|
|
next_generator(T&& t)
|
2016-04-14 11:14:49 +00:00
|
|
|
SPROUT_NOEXCEPT_IF_EXPR(sprout::generators::generator_access_traits<typename std::remove_reference<T>::type>::get_next_generator(std::declval<T>()))
|
2012-09-21 06:43:30 +00:00
|
|
|
{
|
2016-04-14 11:14:49 +00:00
|
|
|
return sprout::generators::generator_access_traits<typename std::remove_reference<T>::type>::get_next_generator(SPROUT_FORWARD(T, t));
|
2012-09-21 06:43:30 +00:00
|
|
|
}
|
|
|
|
} // namespace generators
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_GENERATOR_NEXT_GENERATOR_HPP
|