From 75b10758ba116eabed730d23e957f1d69a1e3cb8 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Tue, 6 Aug 2024 00:34:57 +0200 Subject: Type traits --- asl/meta/BUILD.bazel | 27 ------------------------ asl/meta/empty.hpp | 11 ---------- asl/meta/empty_tests.cpp | 17 --------------- asl/meta/funcs.hpp | 11 ---------- asl/meta/funcs_tests.cpp | 14 ------------- asl/meta/internal/quals.hpp | 16 -------------- asl/meta/internal/refs.hpp | 45 --------------------------------------- asl/meta/internal/types.hpp | 9 -------- asl/meta/quals.hpp | 22 ------------------- asl/meta/quals_tests.cpp | 51 --------------------------------------------- asl/meta/refs.hpp | 21 ------------------- asl/meta/refs_tests.cpp | 33 ----------------------------- asl/meta/types.hpp | 13 ------------ asl/meta/types_tests.cpp | 10 --------- 14 files changed, 300 deletions(-) delete mode 100644 asl/meta/BUILD.bazel delete mode 100644 asl/meta/empty.hpp delete mode 100644 asl/meta/empty_tests.cpp delete mode 100644 asl/meta/funcs.hpp delete mode 100644 asl/meta/funcs_tests.cpp delete mode 100644 asl/meta/internal/quals.hpp delete mode 100644 asl/meta/internal/refs.hpp delete mode 100644 asl/meta/internal/types.hpp delete mode 100644 asl/meta/quals.hpp delete mode 100644 asl/meta/quals_tests.cpp delete mode 100644 asl/meta/refs.hpp delete mode 100644 asl/meta/refs_tests.cpp delete mode 100644 asl/meta/types.hpp delete mode 100644 asl/meta/types_tests.cpp (limited to 'asl/meta') diff --git a/asl/meta/BUILD.bazel b/asl/meta/BUILD.bazel deleted file mode 100644 index e5b44a7..0000000 --- a/asl/meta/BUILD.bazel +++ /dev/null @@ -1,27 +0,0 @@ -cc_library( - name = "meta", - hdrs = [ - "empty.hpp", - "funcs.hpp", - "quals.hpp", - "refs.hpp", - "types.hpp", - ], - srcs = [ - "internal/quals.hpp", - "internal/refs.hpp", - "internal/types.hpp", - ], - visibility = ["//visibility:public"], -) - -[cc_test( - name = "%s_tests" % name, - srcs = [ - "%s_tests.cpp" % name, - ], - deps = [ - ":meta", - ], -) for name in ["empty", "quals", "refs", "types", "funcs"]] - diff --git a/asl/meta/empty.hpp b/asl/meta/empty.hpp deleted file mode 100644 index 9552fbd..0000000 --- a/asl/meta/empty.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "asl/meta/types.hpp" -#include "asl/meta/quals.hpp" - -namespace asl { - -template concept is_void = same, void>; - -} // namespace asl - diff --git a/asl/meta/empty_tests.cpp b/asl/meta/empty_tests.cpp deleted file mode 100644 index c5bf519..0000000 --- a/asl/meta/empty_tests.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "asl/meta/empty.hpp" - -using namespace asl; - -struct Empty {}; - -static_assert(is_void); -static_assert(is_void); -static_assert(is_void); -static_assert(is_void); -static_assert(!is_void); -static_assert(!is_void); -static_assert(!is_void); -static_assert(!is_void); - - -int main() { return 0; } diff --git a/asl/meta/funcs.hpp b/asl/meta/funcs.hpp deleted file mode 100644 index f699dac..0000000 --- a/asl/meta/funcs.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "asl/meta/internal/quals.hpp" -#include "asl/meta/refs.hpp" - -namespace asl { - -template concept is_func = internal::is_const::remove> && !is_any_ref; - -} // namespace asl - diff --git a/asl/meta/funcs_tests.cpp b/asl/meta/funcs_tests.cpp deleted file mode 100644 index f2f40a2..0000000 --- a/asl/meta/funcs_tests.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "asl/meta/funcs.hpp" - -using namespace asl; - -static_assert(!is_func); -static_assert(!is_func); -static_assert(!is_func); -static_assert(!is_func); -static_assert(is_func); -static_assert(is_func); -static_assert(is_func); -static_assert(!is_func); - -int main() { return 0; } diff --git a/asl/meta/internal/quals.hpp b/asl/meta/internal/quals.hpp deleted file mode 100644 index 869cc89..0000000 --- a/asl/meta/internal/quals.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "asl/meta/types.hpp" - -namespace asl::internal { - -template struct const_helper { using add = const T; using remove = T; }; -template struct const_helper { using add = const T; using remove = T; }; - -template concept is_const = same::add>; - -template struct volatile_helper { using add = volatile T; using remove = T; }; -template struct volatile_helper { using add = volatile T; using remove = T; }; - -} // namespace asl::internal - diff --git a/asl/meta/internal/refs.hpp b/asl/meta/internal/refs.hpp deleted file mode 100644 index b21a0a1..0000000 --- a/asl/meta/internal/refs.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include "asl/meta/types.hpp" - -namespace asl::internal { - -template -inline constexpr bool is_referenceable = false; - -template -inline constexpr bool is_referenceable> = true; - -template> -struct as_ref_helper { using lvalue = T; using rvalue = T; }; - -template -struct as_ref_helper { using lvalue = T&; using rvalue = T&&; }; - -template struct un_ref_helper { using type = T; }; -template struct un_ref_helper { using type = T; }; -template struct un_ref_helper { using type = T; }; - -template -struct is_ref_helper -{ - static inline constexpr bool lref = false; - static inline constexpr bool rref = false; -}; - -template -struct is_ref_helper -{ - static inline constexpr bool lref = true; - static inline constexpr bool rref = false; -}; - -template -struct is_ref_helper -{ - static inline constexpr bool lref = false; - static inline constexpr bool rref = true; -}; - -} // namespace asl::internal - diff --git a/asl/meta/internal/types.hpp b/asl/meta/internal/types.hpp deleted file mode 100644 index f635de5..0000000 --- a/asl/meta/internal/types.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -namespace asl::internal { - -template inline constexpr bool is_same = false; -template inline constexpr bool is_same = true; - -} // namespace asl::internal - diff --git a/asl/meta/quals.hpp b/asl/meta/quals.hpp deleted file mode 100644 index 9671043..0000000 --- a/asl/meta/quals.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "asl/meta/types.hpp" -#include "asl/meta/funcs.hpp" -#include "asl/meta/refs.hpp" -#include "asl/meta/internal/quals.hpp" - -namespace asl { - -template concept is_const = internal::is_const; -template concept is_volatile = !is_any_ref && !is_func && same::add>; - -template using as_const_t = internal::const_helper::add; -template using un_const_t = internal::const_helper::remove; - -template using as_volatile_t = internal::volatile_helper::add; -template using un_volatile_t = internal::volatile_helper::remove; - -template using un_qual_t = un_volatile_t>; - -} // namespace asl - diff --git a/asl/meta/quals_tests.cpp b/asl/meta/quals_tests.cpp deleted file mode 100644 index 37ecc6c..0000000 --- a/asl/meta/quals_tests.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "asl/meta/quals.hpp" -#include "asl/meta/types.hpp" - -using namespace asl; - -static_assert(!is_const); -static_assert(is_const); -static_assert(!is_const); -static_assert(is_const); - -static_assert(!is_volatile); -static_assert(!is_volatile); -static_assert(is_volatile); -static_assert(is_volatile); - -static_assert(!is_const); -static_assert(is_const); - -static_assert(is_const); -static_assert(is_const); - -static_assert(is_const); -static_assert(is_const); -static_assert(is_const); - -static_assert(!is_volatile); -static_assert(!is_volatile); - -static_assert(same, const int>); -static_assert(same, const int>); -static_assert(same, int>); -static_assert(same, int>); - -static_assert(same, const int[]>); -static_assert(same, const int[5]>); - -static_assert(same, volatile int>); -static_assert(same, volatile int>); -static_assert(same, int>); -static_assert(same, int>); - -static_assert(same, volatile int[]>); -static_assert(same, volatile int[5]>); - -static_assert(same, int>); -static_assert(same, int>); -static_assert(same, int>); -static_assert(same, int>); -static_assert(same, int>); - -int main() { return 0; } diff --git a/asl/meta/refs.hpp b/asl/meta/refs.hpp deleted file mode 100644 index b72458a..0000000 --- a/asl/meta/refs.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "asl/meta/internal/refs.hpp" - -namespace asl { - -template concept referenceable = internal::is_referenceable; - -template concept is_ref = internal::is_ref_helper::lref; -template concept is_rref = internal::is_ref_helper::rref; -template concept is_any_ref = is_ref || is_rref; - -template using as_ref_t = internal::as_ref_helper::lvalue; -template using as_rref_t = internal::as_ref_helper::rvalue; - -template using un_ref_t = internal::un_ref_helper::type; - -#define AslMove(expr_) (static_cast<::asl::as_rref_t<::asl::un_ref_t>>(expr_)) -#define AslForward(expr_) (static_cast<::asl::as_rref_t>(expr_)) - -} // namespace asl diff --git a/asl/meta/refs_tests.cpp b/asl/meta/refs_tests.cpp deleted file mode 100644 index 49d4f23..0000000 --- a/asl/meta/refs_tests.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "asl/meta/refs.hpp" -#include "asl/meta/types.hpp" - -using namespace asl; - -static_assert(referenceable); -static_assert(referenceable); -static_assert(referenceable); -static_assert(!referenceable); -static_assert(referenceable); -static_assert(referenceable); -static_assert(referenceable); -static_assert(!referenceable); -static_assert(!referenceable); -static_assert(!referenceable); - -static_assert(!is_ref); -static_assert(!is_rref); -static_assert(!is_any_ref); - -static_assert(is_ref); -static_assert(!is_rref); -static_assert(is_any_ref); - -static_assert(!is_ref); -static_assert(is_rref); -static_assert(is_any_ref); - -static_assert(!is_any_ref); -static_assert(!is_any_ref); -static_assert(!is_any_ref); - -int main() { return 0; } diff --git a/asl/meta/types.hpp b/asl/meta/types.hpp deleted file mode 100644 index bfc2998..0000000 --- a/asl/meta/types.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "asl/meta/internal/types.hpp" - -namespace asl { - -template using void_t = void; - -template -concept same = internal::is_same && internal::is_same; - -} // namespace asl - diff --git a/asl/meta/types_tests.cpp b/asl/meta/types_tests.cpp deleted file mode 100644 index 180ecda..0000000 --- a/asl/meta/types_tests.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "asl/meta/types.hpp" - -using namespace asl; - -static_assert(same); -static_assert(same); -static_assert(!same); -static_assert(!same); - -int main() { return 0; } -- cgit