diff options
author | Nikolas Klauser <nikolasklauser@berlin.de> | 2024-03-29 12:06:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 12:06:09 +0100 |
commit | 316634ff5925481201a7b27d5f806cc2361cf4f2 (patch) | |
tree | 1255b506f370511f57a89e522b763c88d5f32127 | |
parent | a85569242da98c29d76fbb303a4014cf6c514a6f (diff) |
[libc++] Remove <queue> and <stack> includes from <format> (#85520)
This reduces the include time of <format> from 691ms to 556ms.
26 files changed, 187 insertions, 43 deletions
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 982b85e4e2d6..07b5e974eaf5 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -430,22 +430,27 @@ set(files __fwd/array.h __fwd/bit_reference.h __fwd/complex.h + __fwd/deque.h __fwd/format.h __fwd/fstream.h __fwd/functional.h __fwd/ios.h __fwd/istream.h __fwd/mdspan.h + __fwd/memory.h __fwd/memory_resource.h __fwd/ostream.h __fwd/pair.h + __fwd/queue.h __fwd/span.h __fwd/sstream.h + __fwd/stack.h __fwd/streambuf.h __fwd/string.h __fwd/string_view.h __fwd/subrange.h __fwd/tuple.h + __fwd/vector.h __hash_table __ios/fpos.h __iterator/access.h diff --git a/libcxx/include/__format/container_adaptor.h b/libcxx/include/__format/container_adaptor.h index ec806ef16bf5..9f49ca03bf4f 100644 --- a/libcxx/include/__format/container_adaptor.h +++ b/libcxx/include/__format/container_adaptor.h @@ -18,11 +18,11 @@ #include <__format/concepts.h> #include <__format/formatter.h> #include <__format/range_default_formatter.h> +#include <__fwd/queue.h> +#include <__fwd/stack.h> #include <__ranges/ref_view.h> #include <__type_traits/is_const.h> #include <__type_traits/maybe_const.h> -#include <queue> -#include <stack> _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/libcxx/include/__fwd/deque.h b/libcxx/include/__fwd/deque.h new file mode 100644 index 000000000000..fd2fb5bb4b8e --- /dev/null +++ b/libcxx/include/__fwd/deque.h @@ -0,0 +1,26 @@ +//===---------------------------------------------------------------------===// +// +// 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_DEQUE_H +#define _LIBCPP___FWD_DEQUE_H + +#include <__config> +#include <__fwd/memory.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp, class _Allocator = allocator<_Tp> > +class _LIBCPP_TEMPLATE_VIS deque; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_DEQUE_H diff --git a/libcxx/include/__fwd/memory.h b/libcxx/include/__fwd/memory.h new file mode 100644 index 000000000000..b9e151855ad7 --- /dev/null +++ b/libcxx/include/__fwd/memory.h @@ -0,0 +1,25 @@ +//===---------------------------------------------------------------------===// +// +// 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_MEMORY_H +#define _LIBCPP___FWD_MEMORY_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +class _LIBCPP_TEMPLATE_VIS allocator; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_MEMORY_H diff --git a/libcxx/include/__fwd/queue.h b/libcxx/include/__fwd/queue.h new file mode 100644 index 000000000000..50d99ad9c29f --- /dev/null +++ b/libcxx/include/__fwd/queue.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_QUEUE_H +#define _LIBCPP___FWD_QUEUE_H + +#include <__config> +#include <__functional/operations.h> +#include <__fwd/deque.h> +#include <__fwd/vector.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp, class _Container = deque<_Tp> > +class _LIBCPP_TEMPLATE_VIS queue; + +template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> > +class _LIBCPP_TEMPLATE_VIS priority_queue; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_QUEUE_H diff --git a/libcxx/include/__fwd/sstream.h b/libcxx/include/__fwd/sstream.h index e2d46fbe1d9b..39a9c3faf1f8 100644 --- a/libcxx/include/__fwd/sstream.h +++ b/libcxx/include/__fwd/sstream.h @@ -10,6 +10,7 @@ #define _LIBCPP___FWD_SSTREAM_H #include <__config> +#include <__fwd/memory.h> #include <__fwd/string.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/libcxx/include/__fwd/stack.h b/libcxx/include/__fwd/stack.h new file mode 100644 index 000000000000..7dab6c1a4f4e --- /dev/null +++ b/libcxx/include/__fwd/stack.h @@ -0,0 +1,26 @@ +//===---------------------------------------------------------------------===// +// +// 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_STACK_H +#define _LIBCPP___FWD_STACK_H + +#include <__config> +#include <__fwd/deque.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp, class _Container = deque<_Tp> > +class _LIBCPP_TEMPLATE_VIS stack; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_STACK_H diff --git a/libcxx/include/__fwd/string.h b/libcxx/include/__fwd/string.h index 032132374de5..320c4e4c8183 100644 --- a/libcxx/include/__fwd/string.h +++ b/libcxx/include/__fwd/string.h @@ -11,6 +11,7 @@ #include <__availability> #include <__config> +#include <__fwd/memory.h> #include <__fwd/memory_resource.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -39,9 +40,6 @@ template <> struct char_traits<wchar_t>; #endif -template <class _Tp> -class _LIBCPP_TEMPLATE_VIS allocator; - template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > class _LIBCPP_TEMPLATE_VIS basic_string; diff --git a/libcxx/include/__fwd/vector.h b/libcxx/include/__fwd/vector.h new file mode 100644 index 000000000000..c9cc96137449 --- /dev/null +++ b/libcxx/include/__fwd/vector.h @@ -0,0 +1,26 @@ +//===---------------------------------------------------------------------===// +// +// 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_VECTOR_H +#define _LIBCPP___FWD_VECTOR_H + +#include <__config> +#include <__fwd/memory.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp, class _Alloc = allocator<_Tp> > +class _LIBCPP_TEMPLATE_VIS vector; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_VECTOR_H diff --git a/libcxx/include/deque b/libcxx/include/deque index 85ea9c6f661e..a6472e46d426 100644 --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -192,6 +192,7 @@ template <class T, class Allocator, class Predicate> #include <__availability> #include <__config> #include <__format/enable_insertable.h> +#include <__fwd/deque.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> @@ -244,9 +245,6 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp, class _Allocator = allocator<_Tp> > -class _LIBCPP_TEMPLATE_VIS deque; - template <class _ValueType, class _DiffType> struct __deque_block_size { static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16; diff --git a/libcxx/include/format b/libcxx/include/format index 146613464534..f1e87de0f830 100644 --- a/libcxx/include/format +++ b/libcxx/include/format @@ -223,6 +223,8 @@ namespace std { #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <locale> +# include <queue> +# include <stack> #endif #endif // _LIBCPP_FORMAT diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd index f1c2cbd96696..9af5e0503185 100644 --- a/libcxx/include/iosfwd +++ b/libcxx/include/iosfwd @@ -110,6 +110,7 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20 #include <__fwd/fstream.h> #include <__fwd/ios.h> #include <__fwd/istream.h> +#include <__fwd/memory.h> #include <__fwd/ostream.h> #include <__fwd/sstream.h> #include <__fwd/streambuf.h> @@ -162,10 +163,6 @@ using wosyncstream = basic_osyncstream<wchar_t>; #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) -// Include other forward declarations here -template <class _Tp, class _Alloc = allocator<_Tp> > -class _LIBCPP_TEMPLATE_VIS vector; - template <class _CharT, class _Traits> class __save_flags { typedef basic_ios<_CharT, _Traits> __stream_type; diff --git a/libcxx/include/libcxx.imp b/libcxx/include/libcxx.imp index 56ea58262828..fb446da5dc6f 100644 --- a/libcxx/include/libcxx.imp +++ b/libcxx/include/libcxx.imp @@ -425,22 +425,27 @@ { include: [ "<__fwd/bit_reference.h>", "private", "<bitset>", "public" ] }, { include: [ "<__fwd/bit_reference.h>", "private", "<vector>", "public" ] }, { include: [ "<__fwd/complex.h>", "private", "<complex>", "public" ] }, + { include: [ "<__fwd/deque.h>", "private", "<deque>", "public" ] }, { include: [ "<__fwd/format.h>", "private", "<format>", "public" ] }, { include: [ "<__fwd/fstream.h>", "private", "<iosfwd>", "public" ] }, { include: [ "<__fwd/functional.h>", "private", "<functional>", "public" ] }, { include: [ "<__fwd/ios.h>", "private", "<iosfwd>", "public" ] }, { include: [ "<__fwd/istream.h>", "private", "<iosfwd>", "public" ] }, { include: [ "<__fwd/mdspan.h>", "private", "<mdspan>", "public" ] }, + { include: [ "<__fwd/memory.h>", "private", "<memory>", "public" ] }, { include: [ "<__fwd/memory_resource.h>", "private", "<memory_resource>", "public" ] }, { include: [ "<__fwd/ostream.h>", "private", "<iosfwd>", "public" ] }, { include: [ "<__fwd/pair.h>", "private", "<utility>", "public" ] }, + { include: [ "<__fwd/queue.h>", "private", "<queue>", "public" ] }, { include: [ "<__fwd/span.h>", "private", "<span>", "public" ] }, { include: [ "<__fwd/sstream.h>", "private", "<iosfwd>", "public" ] }, + { include: [ "<__fwd/stack.h>", "private", "<stack>", "public" ] }, { include: [ "<__fwd/streambuf.h>", "private", "<iosfwd>", "public" ] }, { include: [ "<__fwd/string.h>", "private", "<string>", "public" ] }, { include: [ "<__fwd/string_view.h>", "private", "<string_view>", "public" ] }, { include: [ "<__fwd/subrange.h>", "private", "<ranges>", "public" ] }, { include: [ "<__fwd/tuple.h>", "private", "<tuple>", "public" ] }, + { include: [ "<__fwd/vector.h>", "private", "<vector>", "public" ] }, { include: [ "<__ios/fpos.h>", "private", "<ios>", "public" ] }, { include: [ "<__iterator/access.h>", "private", "<iterator>", "public" ] }, { include: [ "<__iterator/advance.h>", "private", "<iterator>", "public" ] }, diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap index 03d18775631e..079c6234d410 100644 --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -1255,6 +1255,8 @@ module std_private_debug_utils_strict_weak_ordering_check [system] { export std_private_type_traits_is_constant_evaluated } +module std_private_deque_fwd [system] { header "__fwd/deque.h" } + module std_private_exception_exception [system] { header "__exception/exception.h" } module std_private_exception_exception_ptr [system] { header "__exception/exception_ptr.h" @@ -1535,6 +1537,7 @@ module std_private_memory_concepts [system] { } module std_private_memory_construct_at [system] { header "__memory/construct_at.h" } module std_private_memory_destruct_n [system] { header "__memory/destruct_n.h" } +module std_private_memory_fwd [system] { header "__fwd/memory.h" } module std_private_memory_pointer_traits [system] { header "__memory/pointer_traits.h" } module std_private_memory_ranges_construct_at [system] { header "__memory/ranges_construct_at.h" } module std_private_memory_ranges_uninitialized_algorithms [system] { @@ -1600,6 +1603,8 @@ module std_private_numeric_transform_exclusive_scan [system] { header "__numeric module std_private_numeric_transform_inclusive_scan [system] { header "__numeric/transform_inclusive_scan.h" } module std_private_numeric_transform_reduce [system] { header "__numeric/transform_reduce.h" } +module std_private_queue_fwd [system] { header "__fwd/queue.h" } + module std_private_random_bernoulli_distribution [system] { header "__random/bernoulli_distribution.h" } module std_private_random_binomial_distribution [system] { header "__random/binomial_distribution.h" } module std_private_random_cauchy_distribution [system] { header "__random/cauchy_distribution.h" } @@ -1737,6 +1742,8 @@ module std_private_ranges_zip_view [system] { header "__ranges module std_private_span_span_fwd [system] { header "__fwd/span.h" } +module std_private_stack_fwd [system] { header "__fwd/stack.h" } + module std_private_stop_token_atomic_unique_lock [system] { header "__stop_token/atomic_unique_lock.h" } module std_private_stop_token_intrusive_list_view [system] { header "__stop_token/intrusive_list_view.h" } module std_private_stop_token_intrusive_shared_ptr [system] { header "__stop_token/intrusive_shared_ptr.h" } @@ -2085,3 +2092,5 @@ module std_private_utility_to_underlying [system] { header "__utility/t module std_private_utility_unreachable [system] { header "__utility/unreachable.h" } module std_private_variant_monostate [system] { header "__variant/monostate.h" } + +module std_private_vector_fwd [system] { header "__fwd/vector.h" } diff --git a/libcxx/include/queue b/libcxx/include/queue index 521a465713cd..f94cd7671863 100644 --- a/libcxx/include/queue +++ b/libcxx/include/queue @@ -260,6 +260,8 @@ template <class T, class Container, class Compare> #include <__algorithm/ranges_copy.h> #include <__config> #include <__functional/operations.h> +#include <__fwd/deque.h> +#include <__fwd/queue.h> #include <__iterator/back_insert_iterator.h> #include <__iterator/iterator_traits.h> #include <__memory/uses_allocator.h> @@ -287,9 +289,6 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp, class _Container = deque<_Tp> > -class _LIBCPP_TEMPLATE_VIS queue; - template <class _Tp, class _Container> _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y); @@ -511,7 +510,7 @@ template <class _Tp, class _Container, class _Alloc> struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { }; -template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> > +template <class _Tp, class _Container, class _Compare> class _LIBCPP_TEMPLATE_VIS priority_queue { public: typedef _Container container_type; diff --git a/libcxx/include/stack b/libcxx/include/stack index 4003792600a0..08a392da6848 100644 --- a/libcxx/include/stack +++ b/libcxx/include/stack @@ -115,6 +115,7 @@ template <class T, class Container> #include <__algorithm/ranges_copy.h> #include <__config> +#include <__fwd/stack.h> #include <__iterator/back_insert_iterator.h> #include <__iterator/iterator_traits.h> #include <__memory/uses_allocator.h> @@ -142,9 +143,6 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp, class _Container = deque<_Tp> > -class _LIBCPP_TEMPLATE_VIS stack; - template <class _Tp, class _Container> _LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); diff --git a/libcxx/include/vector b/libcxx/include/vector index 0908482600c5..1defc43a5247 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -325,6 +325,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ #include <__format/formatter_bool.h> #include <__functional/hash.h> #include <__functional/unary_function.h> +#include <__fwd/vector.h> #include <__iterator/advance.h> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> @@ -357,7 +358,6 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ #include <__utility/swap.h> #include <climits> #include <cstring> -#include <iosfwd> // for forward declaration of vector #include <limits> #include <stdexcept> #include <version> @@ -2989,6 +2989,7 @@ _LIBCPP_POP_MACROS # include <atomic> # include <concepts> # include <cstdlib> +# include <iosfwd> # include <locale> # include <tuple> # include <type_traits> diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index c65b9b9d705e..2e246644f626 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -267,6 +267,7 @@ filesystem type_traits filesystem version format array format cctype +format cerrno format clocale format cmath format cstddef diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index b3d9e327fc7a..e074bf1f7dcc 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -268,6 +268,7 @@ filesystem type_traits filesystem version format array format cctype +format cerrno format clocale format cmath format cstddef diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index d723409422a3..88f9c24f0864 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -270,6 +270,7 @@ filesystem type_traits filesystem version format array format cctype +format cerrno format clocale format cmath format cstddef diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index d723409422a3..88f9c24f0864 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -270,6 +270,7 @@ filesystem type_traits filesystem version format array format cctype +format cerrno format clocale format cmath format cstddef diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv index 03b4eda8b4d8..27f59660fb98 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx20.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv @@ -281,6 +281,7 @@ filesystem type_traits filesystem version format array format cctype +format cerrno format clocale format cmath format cstddef diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv index 062127364adf..79c67dc00cfb 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx23.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv @@ -190,6 +190,7 @@ filesystem string_view filesystem version format array format cctype +format cerrno format clocale format cmath format cstddef @@ -201,8 +202,6 @@ format initializer_list format limits format new format optional -format queue -format stack format stdexcept format string format string_view @@ -680,7 +679,6 @@ vector cstdlib vector cstring vector cwchar vector initializer_list -vector iosfwd vector limits vector new vector stdexcept diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index 062127364adf..79c67dc00cfb 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -190,6 +190,7 @@ filesystem string_view filesystem version format array format cctype +format cerrno format clocale format cmath format cstddef @@ -201,8 +202,6 @@ format initializer_list format limits format new format optional -format queue -format stack format stdexcept format string format string_view @@ -680,7 +679,6 @@ vector cstdlib vector cstring vector cwchar vector initializer_list -vector iosfwd vector limits vector new vector stdexcept diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.verify.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.verify.cpp index 7ce00d70f844..2b2242e240a2 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.verify.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.verify.cpp @@ -14,25 +14,20 @@ // -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; // -#include <deque> -#include <iterator> #include <cassert> #include <cstddef> - - -int main(int, char**) -{ -// Test the explicit deduction guides - -// Test the implicit deduction guides - { -// vector (allocator &) - std::vector vec((std::allocator<int>())); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'vector'}} -// Note: The extra parens are necessary, since otherwise clang decides it is a function declaration. -// Also, we can't use {} instead of parens, because that constructs a -// deque<allocator<int>, allocator<allocator<int>>> - } - +#include <vector> + +int main(int, char**) { + // Test the explicit deduction guides + // TODO: Should there be tests for explicit deduction guides? + + // Test the implicit deduction guides + { + // vector (allocator &) + // expected-error@+1 {{no viable constructor or deduction guide for deduction of template arguments of 'vector'}} + std::vector vec(std::allocator< int>{}); + } return 0; } diff --git a/libcxx/test/support/deduction_guides_sfinae_checks.h b/libcxx/test/support/deduction_guides_sfinae_checks.h index 8b715da5a34e..0c32b3732413 100644 --- a/libcxx/test/support/deduction_guides_sfinae_checks.h +++ b/libcxx/test/support/deduction_guides_sfinae_checks.h @@ -16,6 +16,7 @@ #include <memory> #include <type_traits> #include <utility> +#include <vector> #include "test_macros.h" #if TEST_STD_VER >= 23 |