[libcxx-commits] [libcxx] [libc++] ~vector: Don't __clear trivial typed elements (PR #86947)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 28 11:02:53 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 de0abc0983d355bbd971c5c571ba4c209a0c63ea 6917d186bbb197356bdeaf663380976c8080aba1 -- libcxx/test/std/containers/sequences/vector/vector.cons/dtor_no_trivial_element_dtor_call.pass.cpp libcxx/include/vector
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_no_trivial_element_dtor_call.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_no_trivial_element_dtor_call.pass.cpp
index 5a5399e2ff..5eafe1191a 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_no_trivial_element_dtor_call.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_no_trivial_element_dtor_call.pass.cpp
@@ -9,77 +9,55 @@
#include <vector>
#include <cassert>
-struct int_alloc
-{
- typedef int value_type;
-
- template< class U >
- struct rebind
- {
- typedef int_alloc other;
- };
-
- int* allocate(std::size_t n)
- {
- return new int[n];
- }
- void deallocate(int* p, std::size_t n)
- {
- for (std::size_t i = 0; i < n; ++i) {
- assert(p[i] != 0);
- }
- delete p;
+struct int_alloc {
+ typedef int value_type;
+
+ template < class U >
+ struct rebind {
+ typedef int_alloc other;
+ };
+
+ int* allocate(std::size_t n) { return new int[n]; }
+ void deallocate(int* p, std::size_t n) {
+ for (std::size_t i = 0; i < n; ++i) {
+ assert(p[i] != 0);
}
+ delete p;
+ }
};
-struct with_dtor
-{
- with_dtor() = default;
- with_dtor(const with_dtor &) = default;
+struct with_dtor {
+ with_dtor() = default;
+ with_dtor(const with_dtor&) = default;
- int x = 42;
+ int x = 42;
- ~with_dtor() {
- x = 0;
- }
+ ~with_dtor() { x = 0; }
};
-struct with_dtor_alloc
-{
- typedef with_dtor value_type;
+struct with_dtor_alloc {
+ typedef with_dtor value_type;
- template< class U >
- struct rebind
- {
- typedef with_dtor_alloc other;
- };
+ template < class U >
+ struct rebind {
+ typedef with_dtor_alloc other;
+ };
- with_dtor* allocate(std::size_t n)
- {
- return new with_dtor[n];
- }
- void deallocate(with_dtor* p, std::size_t n)
- {
- for (std::size_t i = 0; i < n; ++i) {
- assert(p[i].x == 0);
- }
- delete[] p;
+ with_dtor* allocate(std::size_t n) { return new with_dtor[n]; }
+ void deallocate(with_dtor* p, std::size_t n) {
+ for (std::size_t i = 0; i < n; ++i) {
+ assert(p[i].x == 0);
}
+ delete[] p;
+ }
};
-void tests()
-{
- {
- std::vector<with_dtor, with_dtor_alloc> v(5, with_dtor());
- }
- {
- std::vector<int, int_alloc> v(5, 42);
- }
+void tests() {
+ { std::vector<with_dtor, with_dtor_alloc> v(5, with_dtor()); }
+ { std::vector<int, int_alloc> v(5, 42); }
}
-int main(int, char**)
-{
- tests();
- return 0;
+int main(int, char**) {
+ tests();
+ return 0;
}
-
``````````
</details>
https://github.com/llvm/llvm-project/pull/86947
More information about the libcxx-commits
mailing list