1 //===----------------------------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "test_allocator.h" 10 11 using Alloc = test_allocator<int>; 12 13 enum class RefType { 14 LValue, 15 ConstLValue, 16 RValue, 17 ConstRValue, 18 }; 19 20 struct UsesAllocArgT { 21 using allocator_type = Alloc; 22 23 bool allocator_constructed_ = false; 24 Alloc a_; 25 const Alloc& alloc_ = a_; 26 const int* val_ptr_; 27 RefType ref_type_; 28 29 constexpr UsesAllocArgT() = default; UsesAllocArgTUsesAllocArgT30 constexpr UsesAllocArgT(std::allocator_arg_t, const Alloc& alloc) : allocator_constructed_(true), alloc_(alloc) {} UsesAllocArgTUsesAllocArgT31 constexpr UsesAllocArgT(std::allocator_arg_t, const Alloc& alloc, int& val) 32 : allocator_constructed_(true), alloc_(alloc), val_ptr_(&val), ref_type_(RefType::LValue) {} UsesAllocArgTUsesAllocArgT33 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) {} UsesAllocArgTUsesAllocArgT35 constexpr UsesAllocArgT(std::allocator_arg_t, const Alloc& alloc, int&& val) 36 : allocator_constructed_(true), alloc_(alloc), val_ptr_(&val), ref_type_(RefType::RValue) {} UsesAllocArgTUsesAllocArgT37 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) {} 39 }; 40 41 struct UsesAllocLast { 42 using allocator_type = Alloc; 43 44 bool allocator_constructed_ = false; 45 Alloc a_; 46 const Alloc& alloc_ = a_; 47 const int* val_ptr_; 48 RefType ref_type_; 49 50 constexpr UsesAllocLast() = default; UsesAllocLastUsesAllocLast51 constexpr UsesAllocLast(const Alloc& alloc) : allocator_constructed_(true), alloc_(alloc) {} UsesAllocLastUsesAllocLast52 constexpr UsesAllocLast(int& val, const Alloc& alloc) 53 : allocator_constructed_(true), alloc_(alloc), val_ptr_(&val), ref_type_(RefType::LValue) {} UsesAllocLastUsesAllocLast54 constexpr UsesAllocLast(const int& val, const Alloc& alloc) 55 : allocator_constructed_(true), alloc_(alloc), val_ptr_(&val), ref_type_(RefType::ConstLValue) {} UsesAllocLastUsesAllocLast56 constexpr UsesAllocLast(int&& val, const Alloc& alloc) 57 : allocator_constructed_(true), alloc_(alloc), val_ptr_(&val), ref_type_(RefType::RValue) {} UsesAllocLastUsesAllocLast58 constexpr UsesAllocLast(const int&& val, const Alloc& alloc) 59 : allocator_constructed_(true), alloc_(alloc), val_ptr_(&val), ref_type_(RefType::ConstRValue) {} 60 }; 61 62 struct NotAllocatorAware { 63 bool allocator_constructed_ = false; 64 65 constexpr NotAllocatorAware() = default; NotAllocatorAwareNotAllocatorAware66 constexpr NotAllocatorAware(const Alloc&) : allocator_constructed_(true) {} NotAllocatorAwareNotAllocatorAware67 constexpr NotAllocatorAware(const Alloc&, int) : allocator_constructed_(true) {} 68 }; 69 70 struct ConvertibleToPair { 71 constexpr operator std::pair<int, int>() const { return {1, 2}; } 72 }; 73