From a665c590d5089bb4bcb72193542b60ef571409a3 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Thu, 20 Mar 2025 19:28:56 +0100 Subject: Add decay --- asl/base/meta.hpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'asl/base/meta.hpp') diff --git a/asl/base/meta.hpp b/asl/base/meta.hpp index 8bebf2f..93e5603 100644 --- a/asl/base/meta.hpp +++ b/asl/base/meta.hpp @@ -54,6 +54,11 @@ template using as_rref_t = decltype(_as_rref_helper(0))::type; template consteval as_rref_t declval() {} +template auto _as_ptr_helper(int) -> id; +template auto _as_ptr_helper(...) -> id; + +template using as_ptr_t = decltype(_as_ptr_helper(0))::type; + template struct _un_ref_t { using type = T; }; template struct _un_ref_t { using type = T; }; template struct _un_ref_t { using type = T; }; @@ -191,11 +196,23 @@ template concept is_func = _is_func_helper>::value; template concept is_object = !is_void && !is_ref && !is_func; -template struct _is_array_helper : false_type {}; -template struct _is_array_helper : true_type {}; -template struct _is_array_helper : true_type {}; +template struct _array_helper : false_type { using type = T; }; +template struct _array_helper : true_type { using type = T; }; +template struct _array_helper : true_type { using type = T; }; + +template concept is_array = _array_helper::value; -template concept is_array = _is_array_helper::value; +template using remove_extent_t = _array_helper::type; + +template +using decay_t = + select_t< + is_array>, + as_ptr_t>>, + select_t< + is_func>, + as_ptr_t>, + un_cv_t>>>; template struct _is_floating_point_helper : false_type {}; template<> struct _is_floating_point_helper : true_type {}; -- cgit