1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "test_allocator.h"
11 using Alloc
= test_allocator
<int>;
20 struct UsesAllocArgT
{
21 using allocator_type
= Alloc
;
23 bool allocator_constructed_
= false;
25 const Alloc
& alloc_
= a_
;
29 constexpr UsesAllocArgT() = default;
30 constexpr UsesAllocArgT(std::allocator_arg_t
, const Alloc
& alloc
) : allocator_constructed_(true), alloc_(alloc
) {}
31 constexpr UsesAllocArgT(std::allocator_arg_t
, const Alloc
& alloc
, int& val
)
32 : allocator_constructed_(true), alloc_(alloc
), val_ptr_(&val
), ref_type_(RefType::LValue
) {}
33 constexpr UsesAllocArgT(std::allocator_arg_t
, const Alloc
& alloc
, const int& val
)
34 : allocator_constructed_(true), alloc_(alloc
), val_ptr_(&val
), ref_type_(RefType::ConstLValue
) {}
35 constexpr UsesAllocArgT(std::allocator_arg_t
, const Alloc
& alloc
, int&& val
)
36 : allocator_constructed_(true), alloc_(alloc
), val_ptr_(&val
), ref_type_(RefType::RValue
) {}
37 constexpr UsesAllocArgT(std::allocator_arg_t
, const Alloc
& alloc
, const int&& val
)
38 : allocator_constructed_(true), alloc_(alloc
), val_ptr_(&val
), ref_type_(RefType::ConstRValue
) {}
41 struct UsesAllocLast
{
42 using allocator_type
= Alloc
;
44 bool allocator_constructed_
= false;
46 const Alloc
& alloc_
= a_
;
50 constexpr UsesAllocLast() = default;
51 constexpr UsesAllocLast(const Alloc
& alloc
) : allocator_constructed_(true), alloc_(alloc
) {}
52 constexpr UsesAllocLast(int& val
, const Alloc
& alloc
)
53 : allocator_constructed_(true), alloc_(alloc
), val_ptr_(&val
), ref_type_(RefType::LValue
) {}
54 constexpr UsesAllocLast(const int& val
, const Alloc
& alloc
)
55 : allocator_constructed_(true), alloc_(alloc
), val_ptr_(&val
), ref_type_(RefType::ConstLValue
) {}
56 constexpr UsesAllocLast(int&& val
, const Alloc
& alloc
)
57 : allocator_constructed_(true), alloc_(alloc
), val_ptr_(&val
), ref_type_(RefType::RValue
) {}
58 constexpr UsesAllocLast(const int&& val
, const Alloc
& alloc
)
59 : allocator_constructed_(true), alloc_(alloc
), val_ptr_(&val
), ref_type_(RefType::ConstRValue
) {}
62 struct NotAllocatorAware
{
63 bool allocator_constructed_
= false;
65 constexpr NotAllocatorAware() = default;
66 constexpr NotAllocatorAware(const Alloc
&) : allocator_constructed_(true) {}
67 constexpr NotAllocatorAware(const Alloc
&, int) : allocator_constructed_(true) {}
70 struct ConvertibleToPair
{
71 constexpr operator std::pair
<int, int>() const { return {1, 2}; }