Sprout/sprout/generator/generated_value.hpp

43 lines
1.7 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
2016-02-25 09:48:28 +00:00
Copyright (c) 2011-2016 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)
=============================================================================*/
#ifndef SPROUT_GENERATOR_GENERATED_VALUE_HPP
#define SPROUT_GENERATOR_GENERATED_VALUE_HPP
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/generator/generator_access_traits.hpp>
namespace sprout {
namespace generators {
//
// generated_value
//
2013-04-22 14:55:30 +00:00
// effect:
2016-04-14 11:14:49 +00:00
// sprout::generators::generator_access_traits<typename std::remove_reference<T>::type>::get_generated_value(t)
2013-04-22 14:55:30 +00:00
// [default]
2016-04-14 11:14:49 +00:00
// ADL callable get_generated_value(t) -> get_generated_value(t)
// [default]
// callable t.generated_value() -> t.generated_value()
// otherwise -> sprout::tuples::get<0>(t)
2013-04-22 14:55: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_generated_value(std::declval<T>()))
generated_value(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_generated_value(std::declval<T>()))
{
2016-04-14 11:14:49 +00:00
return sprout::generators::generator_access_traits<typename std::remove_reference<T>::type>::get_generated_value(SPROUT_FORWARD(T, t));
}
} // namespace generators
using sprout::generators::generated_value;
} // namespace sprout
#endif // #ifndef SPROUT_GENERATOR_GENERATED_VALUE_HPP