2012-09-21 06:43:30 +00:00
|
|
|
#ifndef SPROUT_GENERATOR_GENERATED_VALUE_HPP
|
|
|
|
#define SPROUT_GENERATOR_GENERATED_VALUE_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-29 08:10:46 +00:00
|
|
|
#include <sprout/adl/not_found.hpp>
|
|
|
|
|
|
|
|
namespace sprout_adl {
|
2012-09-29 14:39:00 +00:00
|
|
|
sprout::not_found_via_adl generated_value(...);
|
2012-09-29 08:10:46 +00:00
|
|
|
} // namespace sprout_adl
|
2012-09-21 06:43:30 +00:00
|
|
|
|
2012-09-26 07:31:11 +00:00
|
|
|
namespace sprout_generator_detail {
|
2012-09-29 08:10:46 +00:00
|
|
|
using sprout_adl::generated_value;
|
2012-09-21 06:43:30 +00:00
|
|
|
|
2013-04-22 04:04:27 +00:00
|
|
|
template<typename Gen>
|
|
|
|
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::generated_value(std::declval<Gen&>()))
|
|
|
|
generated_value(Gen& gen)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::generated_value(std::declval<Gen&>())))
|
|
|
|
{
|
|
|
|
return sprout::generators::generator_access_traits<Gen>::generated_value(gen);
|
|
|
|
}
|
|
|
|
template<typename Gen>
|
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
|
|
|
!std::is_const<Gen>::value && !std::is_volatile<Gen>::value && !std::is_reference<Gen>::value,
|
|
|
|
decltype(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::generated_value(std::declval<Gen&&>()))
|
|
|
|
>::type
|
|
|
|
generated_value(Gen&& gen)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::generated_value(std::declval<Gen&&>())))
|
|
|
|
{
|
|
|
|
return sprout::generators::generator_access_traits<Gen>::generated_value(gen);
|
|
|
|
}
|
|
|
|
template<typename Gen>
|
|
|
|
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen const>::generated_value(std::declval<Gen const&>()))
|
|
|
|
generated_value(Gen const& gen)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen const>::generated_value(std::declval<Gen const&>())))
|
|
|
|
{
|
|
|
|
return sprout::generators::generator_access_traits<Gen const>::generated_value(gen);
|
|
|
|
}
|
2012-09-21 06:43:30 +00:00
|
|
|
|
2013-04-22 04:04:27 +00:00
|
|
|
template<typename Gen>
|
|
|
|
inline SPROUT_CONSTEXPR decltype(generated_value(std::declval<Gen&>()))
|
|
|
|
call_generated_value(Gen& gen)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(generated_value(std::declval<Gen&>())))
|
2012-09-21 06:43:30 +00:00
|
|
|
{
|
2013-04-22 04:04:27 +00:00
|
|
|
return generated_value(gen);
|
2012-09-21 06:43:30 +00:00
|
|
|
}
|
2013-04-22 04:04:27 +00:00
|
|
|
template<typename Gen>
|
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
|
|
|
!std::is_const<Gen>::value && !std::is_volatile<Gen>::value && !std::is_reference<Gen>::value,
|
|
|
|
decltype(generated_value(std::declval<Gen&&>()))
|
|
|
|
>::type
|
|
|
|
call_generated_value(Gen&& gen)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(generated_value(std::declval<Gen&&>())))
|
2012-09-26 09:42:43 +00:00
|
|
|
{
|
2013-04-22 04:04:27 +00:00
|
|
|
return generated_value(gen);
|
2012-09-26 09:42:43 +00:00
|
|
|
}
|
2013-04-22 04:04:27 +00:00
|
|
|
template<typename Gen>
|
|
|
|
inline SPROUT_CONSTEXPR decltype(generated_value(std::declval<Gen const&>()))
|
|
|
|
call_generated_value(Gen const& gen)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(generated_value(std::declval<Gen const&>())))
|
2012-09-21 06:43:30 +00:00
|
|
|
{
|
2013-04-22 04:04:27 +00:00
|
|
|
return generated_value(gen);
|
2012-09-21 06:43:30 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout_generator_detail
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace generators {
|
|
|
|
//
|
|
|
|
// generated_value
|
|
|
|
//
|
|
|
|
template<typename T>
|
2013-04-22 04:04:27 +00:00
|
|
|
inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_generated_value(std::declval<T>()))
|
2012-09-21 06:43:30 +00:00
|
|
|
generated_value(T&& t)
|
2013-04-22 04:04:27 +00:00
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_generator_detail::call_generated_value(std::declval<T>())))
|
2012-09-21 06:43:30 +00:00
|
|
|
{
|
2013-04-22 04:04:27 +00:00
|
|
|
return sprout_generator_detail::call_generated_value(sprout::forward<T>(t));
|
2012-09-21 06:43:30 +00:00
|
|
|
}
|
|
|
|
} // namespace generators
|
|
|
|
|
|
|
|
using sprout::generators::generated_value;
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_GENERATOR_GENERATED_VALUE_HPP
|