2
0
mirror of https://github.com/boostorg/yap.git synced 2026-02-23 16:22:09 +00:00

Add deref().

This commit is contained in:
Zach Laine
2016-11-29 17:31:00 -06:00
parent b0c56cac32
commit 820d614865

View File

@@ -290,6 +290,22 @@ namespace boost::proto17 {
template <long long I>
using placeholder = expression<expr_kind::placeholder, hana::tuple<hana::llong<I>>>;
// TODO: Test all the cases here.
template <typename T>
decltype(auto) deref (T && x)
{
if constexpr (detail::is_expr<T>::value) {
if constexpr (detail::remove_cv_ref_t<T>::kind == expr_kind::expr_ref) {
return ::boost::proto17::value(::boost::proto17::value(static_cast<T &&>(x)));
} else {
return static_cast<T &&>(x);
}
} else {
return static_cast<T &&>(x);
}
}
template <typename Expr>
decltype(auto) value (Expr const & expr)
{