3 Forward declares `boost::hana::eval`.
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_HANA_FWD_EVAL_HPP
11 #define BOOST_HANA_FWD_EVAL_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 namespace boost { namespace hana {
18 //! Evaluate a lazy value and return it.
19 //! @relates hana::lazy
21 //! Given a lazy expression `expr`, `eval` evaluates `expr` and returns
22 //! the result as a normal value. However, for convenience, `eval` can
23 //! also be used with nullary and unary function objects. Specifically,
24 //! if `expr` is not a `hana::lazy`, it is called with no arguments at
25 //! all and the result of that call (`expr()`) is returned. Otherwise,
26 //! if `expr()` is ill-formed, then `expr(hana::id)` is returned instead.
27 //! If that expression is ill-formed, then a compile-time error is
30 //! The reason for allowing nullary callables in `eval` is because this
31 //! allows using nullary lambdas as lazy branches to `eval_if`, which
32 //! is convenient. The reason for allowing unary callables and calling
33 //! them with `hana::id` is because this allows deferring the
34 //! compile-time evaluation of selected expressions inside the callable.
35 //! How this can be achieved is documented by `hana::eval_if`.
40 //! @include example/eval.cpp
41 #ifdef BOOST_HANA_DOXYGEN_INVOKED
42 constexpr auto eval = [](auto&& see_documentation) -> decltype(auto) {
43 return tag-dispatched;
46 template <typename T, typename = void>
47 struct eval_impl : eval_impl<T, when<true>> { };
50 template <typename Expr>
51 constexpr decltype(auto) operator()(Expr&& expr) const;
54 BOOST_HANA_INLINE_VARIABLE constexpr eval_t eval{};
56 }} // end namespace boost::hana
58 #endif // !BOOST_HANA_FWD_EVAL_HPP