#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 generated_value(...); } // namespace sprout_adl namespace sprout_generator_detail { using sprout::tuples::get; using sprout_adl::generated_value; template struct has_adl_generated_value_test { public: template< typename U = T, typename sprout::enabler_if< sprout::is_found_via_adl()))>::value >::type = sprout::enabler > static std::true_type test(int); static std::false_type test(...); }; template struct has_adl_generated_value : public decltype(sprout_generator_detail::has_adl_generated_value_test::test(0)) {}; template struct has_mem_generated_value_test { public: template< typename U = T, typename = decltype(std::declval().generated_value()) > static std::true_type test(int); static std::false_type test(...); }; template struct has_mem_generated_value : public decltype(sprout_generator_detail::has_mem_generated_value_test::test(0)) {}; template struct has_get_generated_value_test { public: template< typename U = T, typename = decltype(get<0>(std::declval())) > static std::true_type test(int); static std::false_type test(...); }; template struct has_get_generated_value : public decltype(sprout_generator_detail::has_get_generated_value_test::test(0)) {}; template struct select_adl_generated_value; template struct select_adl_generated_value< T, typename std::enable_if< sprout_generator_detail::has_adl_generated_value::value >::type > : public std::true_type {}; template struct select_adl_generated_value< T, typename std::enable_if::value )>::type > : public std::false_type {}; template struct select_mem_generated_value; template struct select_mem_generated_value< T, typename std::enable_if< sprout_generator_detail::has_mem_generated_value::value && !sprout_generator_detail::has_adl_generated_value::value >::type > : public std::true_type {}; template struct select_mem_generated_value< T, typename std::enable_if::value && !sprout_generator_detail::has_adl_generated_value::value )>::type > : public std::false_type {}; template struct select_get_generated_value; template struct select_get_generated_value< T, typename std::enable_if< sprout_generator_detail::has_get_generated_value::value && !sprout_generator_detail::has_adl_generated_value::value && !sprout_generator_detail::has_mem_generated_value::value >::type > : public std::true_type {}; template struct select_get_generated_value< T, typename std::enable_if::value && !sprout_generator_detail::has_adl_generated_value::value && !sprout_generator_detail::has_mem_generated_value::value )>::type > : public std::false_type {}; template struct noexcept_generated_value; template struct noexcept_generated_value::value>::type> : public std::integral_constant()), false)> {}; template struct noexcept_generated_value::value>::type> : public std::integral_constant().generated_value(), false)> {}; template struct noexcept_generated_value::value>::type> : public std::integral_constant(std::declval()), false)> {}; template struct generated_value_result; template struct generated_value_result::value>::type> { public: typedef decltype(generated_value(std::declval())) type; }; template struct generated_value_result::value>::type> { public: typedef decltype(std::declval().generated_value()) type; }; template struct generated_value_result::value>::type> { public: typedef decltype(get<0>(std::declval())) type; }; template< typename T, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result::type generated_value_impl(T&& t) SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value::value)) { return generated_value(sprout::forward(t)); } template< typename T, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result::type generated_value_impl(T&& t) SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value::value)) { return sprout::forward(t).generated_value(); } template< typename T, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result::type generated_value_impl(T&& t) SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value::value)) { return get<0>(sprout::forward(t)); } } // namespace sprout_generator_detail namespace sprout { namespace generators { // // generated_value // template inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result::type generated_value(T&& t) SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value::value)) { return sprout_generator_detail::generated_value_impl(sprout::forward(t)); } } // namespace generators using sprout::generators::generated_value; } // namespace sprout #endif // #ifndef SPROUT_GENERATOR_GENERATED_VALUE_HPP