1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 3// 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 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP___MEMORY_USES_ALLOCATOR_H 11#define _LIBCPP___MEMORY_USES_ALLOCATOR_H 12 13#include <__config> 14#include <__type_traits/is_convertible.h> 15#include <cstddef> 16 17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 18# pragma GCC system_header 19#endif 20 21_LIBCPP_BEGIN_NAMESPACE_STD 22 23template <class _Tp> 24struct __has_allocator_type 25{ 26private: 27 template <class _Up> static false_type __test(...); 28 template <class _Up> static true_type __test(typename _Up::allocator_type* = 0); 29public: 30 static const bool value = decltype(__test<_Tp>(0))::value; 31}; 32 33template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value> 34struct __uses_allocator 35 : public integral_constant<bool, 36 is_convertible<_Alloc, typename _Tp::allocator_type>::value> 37{ 38}; 39 40template <class _Tp, class _Alloc> 41struct __uses_allocator<_Tp, _Alloc, false> 42 : public false_type 43{ 44}; 45 46template <class _Tp, class _Alloc> 47struct _LIBCPP_TEMPLATE_VIS uses_allocator 48 : public __uses_allocator<_Tp, _Alloc> 49{ 50}; 51 52#if _LIBCPP_STD_VER > 14 53template <class _Tp, class _Alloc> 54inline constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; 55#endif 56 57_LIBCPP_END_NAMESPACE_STD 58 59#endif // _LIBCPP___MEMORY_USES_ALLOCATOR_H 60