[libcxx-commits] [libcxx] [libc++] Move allocator assertion into allocator_traits (PR #94750)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jun 7 06:08:45 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff b8cc85b318c0dd89e4dd69e3691ffcad5e401885 3515d6bf97276335cc3bf376d64e4c306e3dbcef -- libcxx/include/__memory/allocator_traits.h libcxx/include/deque libcxx/include/forward_list libcxx/include/list libcxx/include/map libcxx/include/set libcxx/include/string libcxx/include/unordered_map libcxx/include/unordered_set libcxx/include/vector libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp libcxx/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
index e461e8811b..44806a240e 100644
--- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
@@ -28,7 +28,10 @@ struct A
{
typedef T value_type;
- template <class U> struct rebind {typedef A<U> other;};
+ template <class U>
+ struct rebind {
+ typedef A<U> other;
+ };
};
template <class T, class U>
@@ -39,7 +42,10 @@ struct B
{
typedef T value_type;
- template <class V> struct rebind {typedef B<V, U> other;};
+ template <class V>
+ struct rebind {
+ typedef B<V, U> other;
+ };
};
template <class T>
@@ -83,19 +89,23 @@ struct G {
int main(int, char**)
{
#if TEST_STD_VER >= 11
- static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>, A<double> >::value), "");
- static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>, B<double, char> >::value), "");
- static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>, C<double> >::value), "");
- static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>, D<double, char> >::value), "");
- static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>, E<double> >::value), "");
- static_assert((std::is_same<std::allocator_traits<F<char> >::rebind_alloc<double>, F<double> >::value), "");
- static_assert((std::is_same<std::allocator_traits<G<char> >::rebind_alloc<double>, G<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>, A<double> >::value), "");
+ static_assert(
+ (std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>, B<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>, C<double> >::value), "");
+ static_assert(
+ (std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>, D<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>, E<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<F<char> >::rebind_alloc<double>, F<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<G<char> >::rebind_alloc<double>, G<double> >::value), "");
#else
- static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>::other, A<double> >::value), "");
- static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>::other, B<double, char> >::value), "");
- static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>::other, C<double> >::value), "");
- static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>::other, D<double, char> >::value), "");
- static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>::other, E<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>::other, A<double> >::value), "");
+ static_assert(
+ (std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>::other, B<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>::other, C<double> >::value), "");
+ static_assert(
+ (std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>::other, D<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>::other, E<double> >::value), "");
#endif
return 0;
diff --git a/libcxx/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
index ff0abbf5a4..d2c1a31ed8 100644
--- a/libcxx/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
@@ -28,7 +28,10 @@ struct A
{
typedef T value_type;
- template <class U> struct rebind {typedef A<U> other;};
+ template <class U>
+ struct rebind {
+ typedef A<U> other;
+ };
};
template <class T, class U>
@@ -39,7 +42,10 @@ struct B
{
typedef T value_type;
- template <class V> struct rebind {typedef B<V, U> other;};
+ template <class V>
+ struct rebind {
+ typedef B<V, U> other;
+ };
};
template <class T>
@@ -65,17 +71,37 @@ struct E
int main(int, char**)
{
#if TEST_STD_VER >= 11
- static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<A<double> > >::value), "");
- static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>, std::allocator_traits<B<double, char> > >::value), "");
- static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value), "");
- static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>, std::allocator_traits<D<double, char> > >::value), "");
- static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value), "");
+ static_assert(
+ (std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<A<double> > >::value),
+ "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>,
+ std::allocator_traits<B<double, char> > >::value),
+ "");
+ static_assert(
+ (std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value),
+ "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>,
+ std::allocator_traits<D<double, char> > >::value),
+ "");
+ static_assert(
+ (std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value),
+ "");
#else
- static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other, std::allocator_traits<A<double> > >::value), "");
- static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other, std::allocator_traits<B<double, char> > >::value), "");
- static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other, std::allocator_traits<C<double> > >::value), "");
- static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other, std::allocator_traits<D<double, char> > >::value), "");
- static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other, std::allocator_traits<E<double> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other,
+ std::allocator_traits<A<double> > >::value),
+ "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other,
+ std::allocator_traits<B<double, char> > >::value),
+ "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other,
+ std::allocator_traits<C<double> > >::value),
+ "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other,
+ std::allocator_traits<D<double, char> > >::value),
+ "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other,
+ std::allocator_traits<E<double> > >::value),
+ "");
#endif
return 0;
``````````
</details>
https://github.com/llvm/llvm-project/pull/94750
More information about the libcxx-commits
mailing list