mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
Implement proposals adopted for C++23: P0401R6, "Providing size feedback in the Allocator interface" P2652R2, "Disallow User Specialization of allocator_traits". This is the minimal conforming implementation, i.e. without the useful parts. Useful parts, to come in future patches, would include giving access to any extra storage reserved, and use of it in vector, string, and other contiguous containers. libstdc++-v3/ChangeLog: PR libstdc++/118030 * include/bits/alloc_traits.h (allocate_at_least (2x)): Define. * include/bits/allocator.h (allocate_at_least): Define. * include/std/memory (__glibcxx_want_allocate_at_least): Define. * include/bits/memoryfwd.h (allocation_result): Define, #include <bits/version.h> first so that will work. * include/bits/version.def (allocate_at_least): Add. * include/bits/version.h: Regenerate. * testsuite/20_util/allocator/allocate_at_least.cc: New test. * testsuite/20_util/allocator/allocate_at_least_neg.cc: New test.
100 lines
2.9 KiB
C++
100 lines
2.9 KiB
C++
// <memory> Forward declarations -*- C++ -*-
|
|
|
|
// Copyright (C) 2001-2026 Free Software Foundation, Inc.
|
|
//
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
// software; you can redistribute it and/or modify it under the
|
|
// terms of the GNU General Public License as published by the
|
|
// Free Software Foundation; either version 3, or (at your option)
|
|
// any later version.
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
/*
|
|
* Copyright (c) 1996-1997
|
|
* Silicon Graphics Computer Systems, Inc.
|
|
*
|
|
* Permission to use, copy, modify, distribute and sell this software
|
|
* and its documentation for any purpose is hereby granted without fee,
|
|
* provided that the above copyright notice appear in all copies and
|
|
* that both that copyright notice and this permission notice appear
|
|
* in supporting documentation. Silicon Graphics makes no
|
|
* representations about the suitability of this software for any
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
*/
|
|
|
|
/** @file bits/memoryfwd.h
|
|
* This is an internal header file, included by other library headers.
|
|
* Do not attempt to use it directly. @headername{memory}
|
|
*/
|
|
|
|
#ifndef _MEMORYFWD_H
|
|
#define _MEMORYFWD_H 1
|
|
|
|
#ifdef _GLIBCXX_SYSHDR
|
|
#pragma GCC system_header
|
|
#endif
|
|
|
|
#include <bits/c++config.h>
|
|
#include <bits/version.h>
|
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
{
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
|
|
/**
|
|
* @defgroup allocators Allocators
|
|
* @ingroup memory
|
|
*
|
|
* Classes encapsulating memory operations.
|
|
*
|
|
* @{
|
|
*/
|
|
|
|
// Included in freestanding as a libstdc++ extension.
|
|
template<typename>
|
|
class allocator;
|
|
|
|
template<>
|
|
class allocator<void>;
|
|
|
|
#if __cplusplus >= 201103L
|
|
/// Declare uses_allocator so it can be specialized in `<queue>` etc.
|
|
template<typename, typename>
|
|
struct uses_allocator;
|
|
|
|
template<typename>
|
|
struct allocator_traits;
|
|
#endif
|
|
|
|
#ifdef __glibcxx_allocate_at_least // C++23
|
|
// Result of, specifically, allocate_at_least(). `count` is the number
|
|
// of objects that may be indexed from `ptr`, not bytes.
|
|
template <typename _Pointer, typename _Size = size_t>
|
|
struct allocation_result
|
|
{
|
|
_Pointer ptr;
|
|
_Size count;
|
|
};
|
|
#endif
|
|
|
|
|
|
/// @} group memory
|
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
} // namespace std
|
|
|
|
#endif
|