diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index d7c36d6b438fb..443e58fffe0d4 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -439,12 +439,14 @@ set(files __fwd/get.h __fwd/ios.h __fwd/istream.h + __fwd/map.h __fwd/mdspan.h __fwd/memory.h __fwd/memory_resource.h __fwd/ostream.h __fwd/pair.h __fwd/queue.h + __fwd/set.h __fwd/span.h __fwd/sstream.h __fwd/stack.h diff --git a/libcxx/include/__functional/operations.h b/libcxx/include/__functional/operations.h index 67d9da289aead..14357ef0a3ca5 100644 --- a/libcxx/include/__functional/operations.h +++ b/libcxx/include/__functional/operations.h @@ -13,6 +13,7 @@ #include <__config> #include <__functional/binary_function.h> #include <__functional/unary_function.h> +#include <__fwd/functional.h> #include <__type_traits/desugars_to.h> #include <__type_traits/is_integral.h> #include <__utility/forward.h> @@ -349,11 +350,7 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to { }; #endif -#if _LIBCPP_STD_VER >= 14 -template -#else template -#endif struct _LIBCPP_TEMPLATE_VIS less : __binary_function<_Tp, _Tp, bool> { typedef bool __result_type; // used by valarray _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { diff --git a/libcxx/include/__fwd/functional.h b/libcxx/include/__fwd/functional.h index 32c9ef33e453b..343a8dc22b8d3 100644 --- a/libcxx/include/__fwd/functional.h +++ b/libcxx/include/__fwd/functional.h @@ -17,6 +17,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#if _LIBCPP_STD_VER >= 14 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS less; + template struct _LIBCPP_TEMPLATE_VIS hash; diff --git a/libcxx/include/__fwd/map.h b/libcxx/include/__fwd/map.h new file mode 100644 index 0000000000000..aad404ca12b8c --- /dev/null +++ b/libcxx/include/__fwd/map.h @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_MAP_H +#define _LIBCPP___FWD_MAP_H + +#include <__config> +#include <__fwd/functional.h> +#include <__fwd/memory.h> +#include <__fwd/pair.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template , class _Allocator = allocator > > +class _LIBCPP_TEMPLATE_VIS map; + +template , class _Allocator = allocator > > +class _LIBCPP_TEMPLATE_VIS multimap; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_MAP_H diff --git a/libcxx/include/__fwd/set.h b/libcxx/include/__fwd/set.h new file mode 100644 index 0000000000000..0ae2c4109c19d --- /dev/null +++ b/libcxx/include/__fwd/set.h @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_SET_H +#define _LIBCPP___FWD_SET_H + +#include <__config> +#include <__fwd/functional.h> +#include <__fwd/memory.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template , class _Allocator = allocator<_Key> > +class _LIBCPP_TEMPLATE_VIS set; + +template , class _Allocator = allocator<_Key> > +class _LIBCPP_TEMPLATE_VIS multiset; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_SET_H diff --git a/libcxx/include/__tree b/libcxx/include/__tree index c627641d5d86f..08ae8996f8f7d 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -13,6 +13,8 @@ #include <__algorithm/min.h> #include <__assert> #include <__config> +#include <__fwd/map.h> +#include <__fwd/set.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> @@ -48,15 +50,6 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -template -class _LIBCPP_TEMPLATE_VIS map; -template -class _LIBCPP_TEMPLATE_VIS multimap; -template -class _LIBCPP_TEMPLATE_VIS set; -template -class _LIBCPP_TEMPLATE_VIS multiset; - template class __tree; template diff --git a/libcxx/include/map b/libcxx/include/map index 37a8ec91b8f1f..e7e0c14e36999 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -582,6 +582,7 @@ erase_if(multimap& c, Predicate pred); // C++20 # include <__functional/binary_function.h> # include <__functional/is_transparent.h> # include <__functional/operations.h> +# include <__fwd/map.h> # include <__iterator/erase_if_container.h> # include <__iterator/iterator_traits.h> # include <__iterator/ranges_iterator_traits.h> @@ -756,10 +757,6 @@ public: } }; -template -class map; -template -class multimap; template class __map_const_iterator; @@ -971,7 +968,7 @@ public: friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; }; -template , class _Allocator = allocator > > +template class _LIBCPP_TEMPLATE_VIS map { public: // types: @@ -1656,7 +1653,7 @@ struct __container_traits > { static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; }; -template , class _Allocator = allocator > > +template class _LIBCPP_TEMPLATE_VIS multimap { public: // types: diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap index b9964dac84acd..99729b3c7b997 100644 --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -1382,7 +1382,10 @@ module std [system] { header "__functional/not_fn.h" export std.functional.perfect_forward // inherited from and using its operators } - module operations { header "__functional/operations.h" } + module operations { + header "__functional/operations.h" + export std_core.fwd.functional + } module perfect_forward { header "__functional/perfect_forward.h" export std.tuple @@ -1548,6 +1551,7 @@ module std [system] { } module map { + module fwd { header "__fwd/map.h" } header "map" export * } @@ -1905,6 +1909,7 @@ module std [system] { } module set { + module fwd { header "__fwd/set.h" } header "set" export * } @@ -1972,7 +1977,7 @@ module std [system] { export std.utility.element_count // used as part of the constexpr C function's API } module extern_template_lists { header "__string/extern_template_lists.h" } - module fwd { header "__fwd/string.h" } + module fwd { header "__fwd/string.h" } header "string" export * diff --git a/libcxx/include/set b/libcxx/include/set index bd7bfef1f3e29..1f60dc7c45bd8 100644 --- a/libcxx/include/set +++ b/libcxx/include/set @@ -522,6 +522,7 @@ erase_if(multiset& c, Predicate pred); // C++20 # include <__config> # include <__functional/is_transparent.h> # include <__functional/operations.h> +# include <__fwd/set.h> # include <__iterator/erase_if_container.h> # include <__iterator/iterator_traits.h> # include <__iterator/ranges_iterator_traits.h> @@ -570,9 +571,6 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template -class multiset; - -template , class _Allocator = allocator<_Key> > class _LIBCPP_TEMPLATE_VIS set { public: // types: @@ -1034,7 +1032,7 @@ struct __container_traits > { static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; }; -template , class _Allocator = allocator<_Key> > +template class _LIBCPP_TEMPLATE_VIS multiset { public: // types: