From a0913e71d5dd91e3f2792cc155cd209bbefd9ffc Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Tue, 29 Nov 2016 23:46:32 -0600 Subject: [PATCH] Add is{, not} expression static_asserts to relevant API. --- expression.hpp | 55 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/expression.hpp b/expression.hpp index 7d1e5ff..a1bcd8d 100644 --- a/expression.hpp +++ b/expression.hpp @@ -307,6 +307,11 @@ namespace boost::proto17 { template decltype(auto) value (Expr && expr) { + static_assert( + detail::is_expr::value, + "value() is only defined for expression templates." + ); + using namespace hana::literals; constexpr expr_kind kind = detail::remove_cv_ref_t::kind; static_assert( @@ -331,6 +336,11 @@ namespace boost::proto17 { template decltype(auto) left (Expr && expr) { + static_assert( + detail::is_expr::value, + "left() is only defined for expression templates." + ); + using namespace hana::literals; constexpr expr_kind kind = detail::remove_cv_ref_t::kind; if constexpr (kind == expr_kind::expr_ref) { @@ -351,6 +361,11 @@ namespace boost::proto17 { template decltype(auto) right (Expr && expr) { + static_assert( + detail::is_expr::value, + "right() is only defined for expression templates." + ); + using namespace hana::literals; constexpr expr_kind kind = detail::remove_cv_ref_t::kind; if constexpr (kind == expr_kind::expr_ref) { @@ -417,7 +432,10 @@ namespace boost::proto17 { template auto make_terminal (T && t) { - static_assert(!detail::is_expr::value); + static_assert( + !detail::is_expr::value, + "make_terminal() is only defined for non expressions." + ); using result_type = detail::operand_type_t; using tuple_type = typename result_type::tuple_type; return result_type{tuple_type{static_cast(t)}}; @@ -426,7 +444,10 @@ namespace boost::proto17 { template