aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test
diff options
context:
space:
mode:
authorNikolas Klauser <nikolasklauser@berlin.de>2024-06-18 11:01:43 +0200
committerGitHub <noreply@github.com>2024-06-18 11:01:43 +0200
commitcb417401879ce70b441a999c4a30f7b64b8d426b (patch)
tree49dcfc7cd5d3e44b689f450819251096be604b4b /libcxx/test
parentbbe4a80605619dcb819ccfee016cf1355fb00af2 (diff)
downloadllvm-cb417401879ce70b441a999c4a30f7b64b8d426b.zip
llvm-cb417401879ce70b441a999c4a30f7b64b8d426b.tar.gz
llvm-cb417401879ce70b441a999c4a30f7b64b8d426b.tar.bz2
[libc++] Refactor<__type_traits/is_swappable.h> (#86822)
This changes the `is_swappable` implementation to use variable templates first and basing the class templates on that. This avoids instantiating them when the `_v` versions are used, which are generally less resource intensive.
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_include_order.pass.cpp27
-rw-r--r--libcxx/test/support/nasty_containers.h20
-rw-r--r--libcxx/test/support/poisoned_hash_helper.h2
3 files changed, 26 insertions, 23 deletions
diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_include_order.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_include_order.pass.cpp
index 5931e7c..1f1709b 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_include_order.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_include_order.pass.cpp
@@ -23,22 +23,21 @@
#include "test_macros.h"
-int main(int, char**)
-{
- // Use a builtin type so we don't get ADL lookup.
- typedef double T[17][29];
- {
- LIBCPP_STATIC_ASSERT(std::__is_swappable<T>::value, "");
+int main(int, char**) {
+ // Use a builtin type so we don't get ADL lookup.
+ typedef double T[17][29];
+ {
+ LIBCPP_STATIC_ASSERT(std::__is_swappable_v<T>, "");
#if TEST_STD_VER > 14
- static_assert(std::is_swappable_v<T>, "");
+ static_assert(std::is_swappable_v<T>, "");
#endif
- }
- {
- T t1 = {};
- T t2 = {};
- std::iter_swap(t1, t2);
- std::swap_ranges(t1, t1 + 17, t2);
- }
+ }
+ {
+ T t1 = {};
+ T t2 = {};
+ std::iter_swap(t1, t2);
+ std::swap_ranges(t1, t1 + 17, t2);
+ }
return 0;
}
diff --git a/libcxx/test/support/nasty_containers.h b/libcxx/test/support/nasty_containers.h
index 91e3af2..34027f0 100644
--- a/libcxx/test/support/nasty_containers.h
+++ b/libcxx/test/support/nasty_containers.h
@@ -123,13 +123,15 @@ public:
void resize(size_type sz) { v_.resize(sz); }
void resize(size_type sz, const value_type& c) { v_.resize(sz, c); }
- void swap(nasty_vector &nv)
+ void swap(nasty_vector& nv)
#if TEST_STD_VER > 14
- noexcept(std::is_nothrow_swappable<nested_container>::value)
+ noexcept(std::is_nothrow_swappable<nested_container>::value)
#elif defined(_LIBCPP_VERSION)
- TEST_NOEXCEPT_COND(std::__is_nothrow_swappable<nested_container>::value)
+ TEST_NOEXCEPT_COND(std::__is_nothrow_swappable_v<nested_container>)
#endif
- { v_.swap(nv.v_); }
+ {
+ v_.swap(nv.v_);
+ }
nasty_vector *operator &() { assert(false); return nullptr; } // nasty
const nasty_vector *operator &() const { assert(false); return nullptr; } // nasty
@@ -252,13 +254,15 @@ public:
void resize(size_type n) { l_.resize(n); }
void resize(size_type n, const value_type& c) { l_.resize(n, c); }
- void swap(nasty_list &nl)
+ void swap(nasty_list& nl)
#if TEST_STD_VER > 14
- noexcept(std::is_nothrow_swappable<nested_container>::value)
+ noexcept(std::is_nothrow_swappable<nested_container>::value)
#elif defined(_LIBCPP_VERSION)
- TEST_NOEXCEPT_COND(std::__is_nothrow_swappable<nested_container>::value)
+ TEST_NOEXCEPT_COND(std::__is_nothrow_swappable_v<nested_container>)
#endif
- { l_.swap(nl.l_); }
+ {
+ l_.swap(nl.l_);
+ }
void clear() TEST_NOEXCEPT { l_.clear(); }
diff --git a/libcxx/test/support/poisoned_hash_helper.h b/libcxx/test/support/poisoned_hash_helper.h
index 000b08c..a073350 100644
--- a/libcxx/test/support/poisoned_hash_helper.h
+++ b/libcxx/test/support/poisoned_hash_helper.h
@@ -145,7 +145,7 @@ TEST_CONSTEXPR_CXX20 void test_hash_enabled(InputKey const& key) {
#if TEST_STD_VER > 14
static_assert(std::is_swappable<Hash>::value, "");
#elif defined(_LIBCPP_VERSION)
- static_assert(std::__is_swappable<Hash>::value, "");
+ static_assert(std::__is_swappable_v<Hash>, "");
#endif
// Hashable requirements