File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed
libcxx/containers/sequences/vector Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 10
10
11
11
// <vector>
12
12
13
+ #include < cstddef>
13
14
#include < vector>
14
15
15
16
#include " test_macros.h"
@@ -22,8 +23,8 @@ struct MyAlloc {
22
23
using value_type = T;
23
24
MyAlloc () = default ;
24
25
template <class U > MyAlloc (const MyAlloc<U>&) {}
25
- T *allocate (int n) { return std::allocator<T>().allocate (n); }
26
- void deallocate (T *p, int n) { return std::allocator<T>().deallocate (p, n); }
26
+ T *allocate (std:: size_t n) { return std::allocator<T>().allocate (n); }
27
+ void deallocate (T *p, std:: size_t n) { return std::allocator<T>().deallocate (p, n); }
27
28
};
28
29
29
30
int main (int , char **)
Original file line number Diff line number Diff line change 11
11
// (bug report: https://llvm.org/PR58392)
12
12
// Check that vector<bool> constructors don't leak memory when an operation inside the constructor throws an exception
13
13
14
+ #include < cstddef>
14
15
#include < type_traits>
15
16
#include < vector>
16
17
@@ -30,10 +31,11 @@ struct Allocator {
30
31
throw 0 ;
31
32
}
32
33
33
- T* allocate (int n) { return std::allocator<T>().allocate (n); }
34
- void deallocate (T* ptr, int n) { std::allocator<T>().deallocate (ptr, n); }
34
+ T* allocate (std:: size_t n) { return std::allocator<T>().allocate (n); }
35
+ void deallocate (T* ptr, std:: size_t n) { std::allocator<T>().deallocate (ptr, n); }
35
36
36
- friend bool operator ==(const Allocator&, const Allocator&) { return false ; }
37
+ template <class U >
38
+ friend bool operator ==(const Allocator&, const Allocator<U>&) { return true ; }
37
39
};
38
40
39
41
template <class IterCat >
Original file line number Diff line number Diff line change 11
11
// (bug report: https://llvm.org/PR58392)
12
12
// Check that vector constructors don't leak memory when an operation inside the constructor throws an exception
13
13
14
+ #include < cstddef>
14
15
#include < type_traits>
15
16
#include < vector>
16
17
@@ -22,15 +23,19 @@ struct Allocator {
22
23
using value_type = T;
23
24
using is_always_equal = std::false_type;
24
25
26
+ template <class U >
27
+ Allocator (const Allocator<U>&) {}
28
+
25
29
Allocator (bool should_throw = true ) {
26
30
if (should_throw)
27
31
throw 0 ;
28
32
}
29
33
30
- T* allocate (int n) { return std::allocator<T>().allocate (n); }
31
- void deallocate (T* ptr, int n) { std::allocator<T>().deallocate (ptr, n); }
34
+ T* allocate (std:: size_t n) { return std::allocator<T>().allocate (n); }
35
+ void deallocate (T* ptr, std:: size_t n) { std::allocator<T>().deallocate (ptr, n); }
32
36
33
- friend bool operator ==(const Allocator&, const Allocator&) { return false ; }
37
+ template <class U >
38
+ friend bool operator ==(const Allocator&, const Allocator<U>&) { return true ; }
34
39
};
35
40
36
41
struct ThrowingT {
You can’t perform that action at this time.
0 commit comments