/*! @file Defines `boost::hana::eval`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_EVAL_HPP #define BOOST_HANA_EVAL_HPP #include #include #include #include #include namespace boost { namespace hana { //! @cond template constexpr decltype(auto) eval_t::operator()(Expr&& expr) const { return eval_impl::type>::apply( static_cast(expr) ); } //! @endcond template struct eval_impl> : default_ { template static constexpr auto eval_helper(Expr&& expr, int) -> decltype(static_cast(expr)()) { return static_cast(expr)(); } template static constexpr auto eval_helper(Expr&& expr, long) -> decltype(static_cast(expr)(hana::id)) { return static_cast(expr)(hana::id); } template static constexpr auto eval_helper(Expr&&, ...) { static_assert(detail::wrong{}, "hana::eval(expr) requires the expression to be a hana::lazy, " "a nullary Callable or a unary Callable that may be " "called with hana::id"); } template static constexpr decltype(auto) apply(Expr&& expr) { return eval_helper(static_cast(expr), int{}); } }; }} // end namespace boost::hana #endif // !BOOST_HANA_EVAL_HPP