
This change moves the definitions of feature test macros (or strictly speaking, the requests for <bits/version.h> to define them) so that only standard headers define them. For example, <bits/shared_ptr.h> will no longer define macros related to std::shared_ptr, only <memory> and <version> will define them. This means that __cpp_lib_shared_ptr_arrays will not be defined by <future> or by other headers that include <bits/shared_ptr.h>. It will only be defined when <memory> has been included. This will discourage users from relying on transitive includes. As a result, internal headers that need to query the macros should use the internal macros like __glibcxx_shared_ptr_arrays instead of __cpp_lib_shared_ptr_arrays, as those internal macros are defined by the internal headers after icluding <bits/version.h>. There are some exceptions to this rule, because __cpp_lib_is_constant_evaluated is defined by bits/c++config.h and so is available everywhere, and __cpp_lib_three_way_comparison is defined by <compare> which several headers are explicitly specified to include, so its macro is guaranteed to be usable too. N.B. not many internal headers actually need an explicit include of <bits/version.h>, because most of them include <type_traits> and so get all the __glibcxx_foo internal macros from there. libstdc++-v3/ChangeLog: * include/bits/algorithmfwd.h: Do not define standard feature test macro here. * include/bits/align.h: Likewise. Test internal macros instead of standard macros. * include/bits/alloc_traits.h: Likewise. * include/bits/allocator.h: Likewise. * include/bits/atomic_base.h: Likewise. * include/bits/atomic_timed_wait.h: Likewise. * include/bits/atomic_wait.h: Likewise. * include/bits/basic_string.h: Likewise. * include/bits/basic_string.tcc: Likewise. * include/bits/char_traits.h: Likewise. * include/bits/chrono.h: Likewise. * include/bits/cow_string.h: Likewise. * include/bits/forward_list.h: Likewise. * include/bits/hashtable.h: Likewise. * include/bits/ios_base.h: Likewise. * include/bits/memory_resource.h: Likewise. * include/bits/move.h: Likewise. * include/bits/move_only_function.h: Likewise. * include/bits/node_handle.h: Likewise. * include/bits/ptr_traits.h: Likewise. * include/bits/range_access.h: Likewise. * include/bits/ranges_algo.h: Likewise. * include/bits/ranges_cmp.h: Likewise. * include/bits/ranges_util.h: Likewise. * include/bits/semaphore_base.h: Likewise. * include/bits/shared_ptr.h: Likewise. * include/bits/shared_ptr_atomic.h: Likewise. * include/bits/shared_ptr_base.h: Likewise. * include/bits/stl_algo.h: Likewise. * include/bits/stl_algobase.h: Likewise. * include/bits/stl_function.h: Likewise. * include/bits/stl_iterator.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_map.h: Likewise. * include/bits/stl_pair.h: Likewise. * include/bits/stl_queue.h: Likewise. * include/bits/stl_stack.h: Likewise. * include/bits/stl_tree.h: Likewise. * include/bits/stl_uninitialized.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/unique_ptr.h: Likewise. * include/bits/unordered_map.h: Likewise. * include/bits/uses_allocator_args.h: Likewise. * include/bits/utility.h: Likewise. * include/bits/erase_if.h: Add comment. * include/std/algorithm: Define standard feature test macros here. * include/std/atomic: Likewise. * include/std/array: Likewise. * include/std/chrono: Likewise. * include/std/condition_variable: Likewise. * include/std/deque: Likewise. * include/std/format: Likewise. * include/std/functional: Likewise. * include/std/forward_list: Likewise. * include/std/ios: Likewise. * include/std/iterator: Likewise. * include/std/list: Likewise. * include/std/map: Likewise. * include/std/memory: Likewise. * include/std/numeric: Likewise. * include/std/queue: Likewise. * include/std/ranges: Likewise. * include/std/regex: Likewise. * include/std/set: Likewise. * include/std/stack: Likewise. * include/std/stop_token: Likewise. * include/std/string: Likewise. * include/std/string_view: * include/std/tuple: Likewise. * include/std/unordered_map: * include/std/unordered_set: * include/std/utility: Likewise. * include/std/vector: Likewise. * include/std/scoped_allocator: Query internal macros instead of standard macros.
110 lines
3.6 KiB
C++
110 lines
3.6 KiB
C++
// <unordered_map> -*- C++ -*-
|
|
|
|
// Copyright (C) 2007-2023 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/>.
|
|
|
|
/** @file include/unordered_map
|
|
* This is a Standard C++ Library header.
|
|
*/
|
|
|
|
#ifndef _GLIBCXX_UNORDERED_MAP
|
|
#define _GLIBCXX_UNORDERED_MAP 1
|
|
|
|
#pragma GCC system_header
|
|
|
|
#include <bits/requires_hosted.h> // container
|
|
|
|
#if __cplusplus < 201103L
|
|
# include <bits/c++0x_warning.h>
|
|
#else
|
|
|
|
#include <initializer_list>
|
|
#include <bits/unordered_map.h>
|
|
#include <bits/range_access.h>
|
|
#include <bits/erase_if.h>
|
|
|
|
#ifdef _GLIBCXX_DEBUG
|
|
# include <debug/unordered_map>
|
|
#endif
|
|
|
|
#define __glibcxx_want_erase_if
|
|
#define __glibcxx_want_generic_unordered_lookup
|
|
#define __glibcxx_want_node_extract
|
|
#define __glibcxx_want_nonmember_container_access
|
|
#define __glibcxx_want_unordered_map_try_emplace
|
|
#include <bits/version.h>
|
|
|
|
#if __cplusplus >= 201703L
|
|
#include <bits/memory_resource.h>
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
{
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
namespace pmr
|
|
{
|
|
template<typename _Key, typename _Tp, typename _Hash = std::hash<_Key>,
|
|
typename _Pred = std::equal_to<_Key>>
|
|
using unordered_map
|
|
= std::unordered_map<_Key, _Tp, _Hash, _Pred,
|
|
polymorphic_allocator<pair<const _Key, _Tp>>>;
|
|
template<typename _Key, typename _Tp, typename _Hash = std::hash<_Key>,
|
|
typename _Pred = std::equal_to<_Key>>
|
|
using unordered_multimap
|
|
= std::unordered_multimap<_Key, _Tp, _Hash, _Pred,
|
|
polymorphic_allocator<pair<const _Key, _Tp>>>;
|
|
} // namespace pmr
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
} // namespace std
|
|
#endif // C++17
|
|
|
|
#if __cplusplus > 201703L
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
{
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
|
|
typename _Alloc, typename _Predicate>
|
|
inline typename unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>::size_type
|
|
erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
|
|
_Predicate __pred)
|
|
{
|
|
_GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>&
|
|
__ucont = __cont;
|
|
return __detail::__erase_nodes_if(__cont, __ucont, __pred);
|
|
}
|
|
|
|
template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
|
|
typename _Alloc, typename _Predicate>
|
|
inline typename unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>::
|
|
size_type
|
|
erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
|
|
_Predicate __pred)
|
|
{
|
|
_GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>&
|
|
__ucont = __cont;
|
|
return __detail::__erase_nodes_if(__cont, __ucont, __pred);
|
|
}
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
} // namespace std
|
|
#endif // C++20
|
|
|
|
#endif // C++11
|
|
|
|
#endif // _GLIBCXX_UNORDERED_MAP
|