2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___MEMORY_USES_ALLOCATOR_H
11 #define _LIBCPP___MEMORY_USES_ALLOCATOR_H
15 #include <type_traits>
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #pragma GCC system_header
21 _LIBCPP_BEGIN_NAMESPACE_STD
24 struct __has_allocator_type
27 struct __two
{char __lx
; char __lxx
;};
28 template <class _Up
> static __two
__test(...);
29 template <class _Up
> static char __test(typename
_Up::allocator_type
* = 0);
31 static const bool value
= sizeof(__test
<_Tp
>(0)) == 1;
34 template <class _Tp
, class _Alloc
, bool = __has_allocator_type
<_Tp
>::value
>
35 struct __uses_allocator
36 : public integral_constant
<bool,
37 is_convertible
<_Alloc
, typename
_Tp::allocator_type
>::value
>
41 template <class _Tp
, class _Alloc
>
42 struct __uses_allocator
<_Tp
, _Alloc
, false>
47 template <class _Tp
, class _Alloc
>
48 struct _LIBCPP_TEMPLATE_VIS uses_allocator
49 : public __uses_allocator
<_Tp
, _Alloc
>
53 #if _LIBCPP_STD_VER > 14
54 template <class _Tp
, class _Alloc
>
55 inline constexpr size_t uses_allocator_v
= uses_allocator
<_Tp
, _Alloc
>::value
;
58 _LIBCPP_END_NAMESPACE_STD
60 #endif // _LIBCPP___MEMORY_USES_ALLOCATOR_H