Go to the documentation of this file.
23 #ifndef ABSL_MEMORY_MEMORY_H_
24 #define ABSL_MEMORY_MEMORY_H_
30 #include <type_traits>
33 #include "absl/base/macros.h"
34 #include "absl/meta/type_traits.h"
75 return std::unique_ptr<T>(
ptr);
78 namespace memory_internal {
87 using array = std::unique_ptr<T[]>;
89 template <
typename T,
size_t N>
100 #if (__cplusplus > 201103L || defined(_MSC_VER)) && \
101 !(defined(__GLIBCXX__) && !defined(__cpp_lib_make_unique))
167 template <
typename T,
typename...
Args>
170 return std::unique_ptr<T>(
new T(std::forward<Args>(
args)...));
177 template <
typename T>
184 template <
typename T,
typename...
Args>
186 Args&&... ) =
delete;
196 template <
typename T>
199 return (
ptr !=
nullptr) ? std::addressof(*
ptr) :
nullptr;
201 inline std::nullptr_t
RawPtr(std::nullptr_t) {
return nullptr; }
226 template <
typename T,
typename D>
228 return ptr ? std::shared_ptr<T>(
std::move(
ptr)) : std::shared_ptr<T>();
246 template <
typename T>
248 return std::weak_ptr<T>(
ptr);
251 namespace memory_internal {
254 template <
template <
typename>
class Extract,
typename Obj,
typename Default,
260 template <
template <
typename>
class Extract,
typename Obj,
typename Default>
265 template <
template <
typename>
class Extract,
typename Obj,
typename Default>
269 template <
typename T>
272 template <
typename T>
275 template <
typename T>
278 template <
typename T>
281 template <
typename T>
284 template <
typename T>
287 template <
typename T>
289 typename T::propagate_on_container_copy_assignment;
291 template <
typename T>
293 typename T::propagate_on_container_move_assignment;
295 template <
typename T>
298 template <
typename T>
301 template <
typename T>
304 template <
template <
typename...>
class Class,
typename T,
typename...
Args>
309 template <
typename Ptr,
typename =
void>
314 template <
typename T>
316 using type =
typename T::element_type;
319 template <
typename T,
typename U>
322 template <
template <
typename...>
class Class,
typename T,
typename...
Args,
328 template <
typename T,
typename U,
typename =
void>
333 template <
typename T,
typename U>
338 template <
typename T,
typename U>
343 template <
typename T,
typename U>
348 template <typename T, typename U, bool = HasRebindAlloc<T, U>(
nullptr)>
353 template <
typename T,
typename U>
371 template <
typename Ptr>
389 template <
typename U>
395 return Ptr::pointer_to(
r);
400 template <
typename T>
406 template <
typename U>
413 return std::addressof(
r);
423 #if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
424 using std::allocator_traits;
425 #else // __cplusplus >= 201703L
426 template <
typename Alloc>
445 template rebind<const value_type>>;
504 template <
typename T>
509 template <
typename T>
516 return a.allocate(
n);
538 template <
typename T,
typename...
Args>
546 template <
typename T>
564 template <
typename A>
567 -> decltype(
a.allocate(n, hint)) {
568 return a.allocate(
n, hint);
572 return a.allocate(
n);
575 template <
typename A,
typename...
Args>
578 -> decltype(
a.construct(std::forward<Args>(
args)...)) {
579 a.construct(std::forward<Args>(
args)...);
582 template <
typename T,
typename...
Args>
584 ::new (
static_cast<void*
>(p))
T(std::forward<Args>(
args)...);
587 template <
typename A,
typename T>
589 T* p) -> decltype(
a.destroy(p)) {
592 template <
typename T>
597 template <
typename A>
605 template <
typename A>
607 -> decltype(
a.select_on_container_copy_construction()) {
608 return a.select_on_container_copy_construction();
615 #endif // __cplusplus >= 201703L
617 namespace memory_internal {
621 template <
typename Alloc>
645 template <
typename Alloc>
650 #if defined(ABSL_ALLOCATOR_NOTHROW) && ABSL_ALLOCATOR_NOTHROW
651 template <
typename T>
658 namespace memory_internal {
659 template <
typename Allocator,
typename Iterator,
typename...
Args>
677 template <
typename Allocator,
typename Iterator,
typename InputIterator>
679 InputIterator last) {
681 static_cast<void>(++
cur),
static_cast<void>(++
first)) {
687 while (
cur != destination) {
699 #endif // ABSL_MEMORY_MEMORY_H_
std::weak_ptr< T > WeakenPtr(const std::shared_ptr< T > &ptr)
static auto construct_impl(int, A &a, Args &&... args) -> decltype(a.construct(std::forward< Args >(args)...))
typename GetFirstArg< Ptr >::type type
typename Alloc::value_type value_type
typename T::propagate_on_container_swap GetPropagateOnContainerSwap
memory_internal::ExtractOrT< memory_internal::GetPropagateOnContainerSwap, Alloc, std::false_type > propagate_on_container_swap
memory_internal::ExtractOrT< memory_internal::GetPropagateOnContainerMoveAssignment, Alloc, std::false_type > propagate_on_container_move_assignment
integral_constant< bool, true > true_type
std::ptrdiff_t difference_type
typename T::const_pointer GetConstPointer
integral_constant< bool, false > false_type
std::unique_ptr< T > scalar
typename T::difference_type GetDifferenceType
memory_internal::ExtractOrT< memory_internal::GetPointer, Alloc, value_type * > pointer
void CopyRange(Allocator &alloc, Iterator destination, InputIterator first, InputIterator last)
typename memory_internal::ElementType< Ptr >::type element_type
memory_internal::ExtractOrT< memory_internal::GetDifferenceType, Ptr, std::ptrdiff_t > difference_type
typename T::element_type type
memory_internal::MakeUniqueResult< T >::scalar make_unique(Args &&... args)
#define ABSL_NAMESPACE_END
static void construct(Alloc &a, T *p, Args &&... args)
static void construct_impl(char, Alloc &, T *p, Args &&... args)
typename RebindFirstArg< T, U >::type type
#define T(upbtypeconst, upbtype, ctype, default_value)
static pointer pointer_to(element_type &r) noexcept
static pointer allocate_impl(char, Alloc &a, size_type n, const_void_pointer)
typename T::template rebind< U >::other type
static pointer pointer_to(element_type &r)
typename T::propagate_on_container_copy_assignment GetPropagateOnContainerCopyAssignment
#define ABSL_NAMESPACE_BEGIN
typename RebindFirstArg< T, U >::type type
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
memory_internal::ExtractOrT< memory_internal::GetDifferenceType, Alloc, typename absl::pointer_traits< pointer >::difference_type > difference_type
memory_internal::ExtractOrT< memory_internal::GetConstPointer, Alloc, typename absl::pointer_traits< pointer >::template rebind< const value_type > > const_pointer
auto RawPtr(T &&ptr) -> decltype(std::addressof(*ptr))
memory_internal::ExtractOrT< memory_internal::GetIsAlwaysEqual, Alloc, typename std::is_empty< Alloc >::type > is_always_equal
constexpr bool HasRebindAlloc(...)
typename T::is_always_equal GetIsAlwaysEqual
static auto select_on_container_copy_construction_impl(int, const A &a) -> decltype(a.select_on_container_copy_construction())
static Alloc select_on_container_copy_construction(const Alloc &a)
std::shared_ptr< T > ShareUniquePtr(std::unique_ptr< T, D > &&ptr)
void * Alloc(FlagOpFn op)
static auto destroy_impl(int, A &a, T *p) -> decltype(a.destroy(p))
static size_type max_size(const Alloc &a)
typename memory_internal::RebindPtr< Ptr, U >::type rebind
typename T::const_void_pointer GetConstVoidPointer
typename T::pointer GetPointer
ABSL_NAMESPACE_BEGIN std::unique_ptr< T > WrapUnique(T *ptr)
memory_internal::ExtractOrT< memory_internal::GetConstVoidPointer, Alloc, typename absl::pointer_traits< pointer >::template rebind< const void > > const_void_pointer
static auto allocate_impl(int, A &a, size_type n, const_void_pointer hint) -> decltype(a.allocate(n, hint))
typename type_traits_internal::VoidTImpl< Ts... >::type void_t
typename T::propagate_on_container_move_assignment GetPropagateOnContainerMoveAssignment
static pointer allocate(Alloc &a, size_type n)
static std::function< void(void *, Slot *, Slot)> construct
void ConstructRange(Allocator &alloc, Iterator first, Iterator last, const Args &... args)
#define ABSL_INTERNAL_CATCH_ANY
#define ABSL_INTERNAL_TRY
memory_internal::ExtractOrT< memory_internal::GetSizeType, Alloc, typename std::make_unsigned< difference_type >::type > size_type
typename ExtractOr< Extract, Obj, Default, void >::type ExtractOrT
memory_internal::MakeUniqueResult< T >::invalid make_unique(Args &&...)=delete
typename T::size_type GetSizeType
static Alloc select_on_container_copy_construction_impl(char, const Alloc &a)
static pointer allocate(Alloc &a, size_type n, const_void_pointer hint)
typename T::void_pointer GetVoidPointer
typename std::remove_extent< T >::type remove_extent_t
memory_internal::ExtractOrT< memory_internal::GetVoidPointer, Alloc, typename absl::pointer_traits< pointer >::template rebind< void > > void_pointer
static void deallocate(Alloc &a, pointer p, size_type n)
static void destroy(Alloc &a, T *p)
typename memory_internal::RebindAlloc< Alloc, T >::type rebind_alloc
typename Alloc::is_nothrow GetIsNothrow
std::allocator< int > alloc
static std::function< void(void *, Slot *)> destroy
static auto max_size_impl(int, const A &a) -> decltype(a.max_size())
#define ABSL_INTERNAL_RETHROW
static void destroy_impl(char, Alloc &, T *p)
memory_internal::ExtractOrT< memory_internal::GetPropagateOnContainerCopyAssignment, Alloc, std::false_type > propagate_on_container_copy_assignment
static size_type max_size_impl(char, const Alloc &)
const typedef T * const_pointer
typename T::template rebind< U > type
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:23