/*============================================================================= Copyright (c) 2011-2015 Bolero MURAKAMI 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) =============================================================================*/ #ifndef SPROUT_GENERATOR_GENERATED_VALUE_HPP #define SPROUT_GENERATOR_GENERATED_VALUE_HPP #include #include #include #include #include #include namespace sprout_adl { sprout::not_found_via_adl get_generated_value(...); } // namespace sprout_adl namespace sprout_generator_detail { using sprout_adl::get_generated_value; template inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits::get_generated_value(std::declval())) get_generated_value(Gen& gen) SPROUT_NOEXCEPT_IF_EXPR(sprout::generators::generator_access_traits::get_generated_value(std::declval())) { return sprout::generators::generator_access_traits::get_generated_value(gen); } template inline SPROUT_CONSTEXPR typename std::enable_if< !std::is_const::value && !std::is_volatile::value && !std::is_reference::value, decltype(sprout::generators::generator_access_traits::type>::get_generated_value(std::declval())) >::type get_generated_value(Gen&& gen) SPROUT_NOEXCEPT_IF_EXPR(sprout::generators::generator_access_traits::type>::get_generated_value(std::declval())) { return sprout::generators::generator_access_traits::get_generated_value(gen); } template inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits::get_generated_value(std::declval())) get_generated_value(Gen const& gen) SPROUT_NOEXCEPT_IF_EXPR(sprout::generators::generator_access_traits::get_generated_value(std::declval())) { return sprout::generators::generator_access_traits::get_generated_value(gen); } template inline SPROUT_CONSTEXPR decltype(get_generated_value(std::declval())) call_get_generated_value(Gen& gen) SPROUT_NOEXCEPT_IF_EXPR(get_generated_value(std::declval())) { return get_generated_value(gen); } template inline SPROUT_CONSTEXPR typename std::enable_if< !std::is_const::value && !std::is_volatile::value && !std::is_reference::value, decltype(get_generated_value(std::declval())) >::type call_get_generated_value(Gen&& gen) SPROUT_NOEXCEPT_IF_EXPR(get_generated_value(std::declval())) { return get_generated_value(gen); } template inline SPROUT_CONSTEXPR decltype(get_generated_value(std::declval())) call_get_generated_value(Gen const& gen) SPROUT_NOEXCEPT_IF_EXPR(get_generated_value(std::declval())) { return get_generated_value(gen); } } // namespace sprout_generator_detail namespace sprout { namespace generators { // // generated_value // // effect: // ADL callable get_generated_value(t) -> get_generated_value(t) // otherwise -> sprout::generators::generator_access_traits::get_generated_value(t) // [default] // member callable t.generated_value() -> t.generated_value() // otherwise -> sprout::tuples::get<0>(t) // template inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_get_generated_value(std::declval())) generated_value(T&& t) SPROUT_NOEXCEPT_IF_EXPR(sprout_generator_detail::call_get_generated_value(std::declval())) { return sprout_generator_detail::call_get_generated_value(SPROUT_FORWARD(T, t)); } } // namespace generators using sprout::generators::generated_value; } // namespace sprout #endif // #ifndef SPROUT_GENERATOR_GENERATED_VALUE_HPP