From 4ad4091b38faa39ddd2deae7455bd3a26531994f Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Thu, 15 Aug 2024 23:35:01 +0200 Subject: Some work on object & init-related traits --- asl/meta.hpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'asl/meta.hpp') diff --git a/asl/meta.hpp b/asl/meta.hpp index c55500a..614fa5d 100644 --- a/asl/meta.hpp +++ b/asl/meta.hpp @@ -2,6 +2,8 @@ namespace asl { +template struct id { using type = T; }; + template struct integral_constant { static constexpr T value = kValue; }; template using bool_constant = integral_constant; @@ -13,6 +15,39 @@ template struct _select_helper template using select_t = _select_helper::type; +template auto _as_lref_helper(int) -> id; +template auto _as_lref_helper(...) -> id; + +template auto _as_rref_helper(int) -> id; +template auto _as_rref_helper(...) -> id; + +template using as_lref_t = decltype(_as_lref_helper(0))::type; +template using as_rref_t = decltype(_as_rref_helper(0))::type; + +template concept constructible = __is_constructible(T, Args...); + +template concept default_constructible = constructible; +template concept copy_constructible = constructible>; +template concept move_constructible = constructible>; + +template concept trivially_constructible = __is_trivially_constructible(T, Args...); + +template concept trivially_default_constructible = trivially_constructible; +template concept trivially_copy_constructible = trivially_constructible>; +template concept trivially_move_constructible = trivially_constructible>; + +template concept assignable = __is_assignable(T, Args...); + +template concept copy_assignable = assignable, as_lref_t>; +template concept move_assignable = assignable, as_rref_t>; + +template concept trivially_assignable = __is_trivially_assignable(T, Args...); + +template concept trivially_copy_assignable = trivially_assignable, as_lref_t>; +template concept trivially_move_assignable = trivially_assignable, as_rref_t>; + +template concept trivially_destructible = __is_trivially_destructible(T); + using nullptr_t = decltype(nullptr); template struct un_ref { using type = T; }; -- cgit