diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-05-13 16:16:26 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-10-01 20:36:55 +0100 |
commit | b7e8fb5e48279ffa5f424e3dd0bb3dfcbe69f5d5 (patch) | |
tree | 0f0453d96969b192623248f0bd9ab17d70658710 /libstdc++-v3/include/bits/stl_queue.h | |
parent | 6ccffeb56b92041991aba923545532087e1977f5 (diff) | |
download | gcc-b7e8fb5e48279ffa5f424e3dd0bb3dfcbe69f5d5.tar.gz |
libstdc++: Add container adaptor constructors taking iterators (P1425R4)
This adds a feature that was recently added to the C++23 working draft.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/stl_queue.h
(__cpp_lib_adaptor_iterator_pair_constructor): Define for C++23, as
per P1425R4.
(queue(InputIterator, InputIterator)): Likewise.
(queue(InputIterator, InputIterator, const Alloc&)): Likewise.
* include/bits/stl_stack.h
(__cpp_lib_adaptor_iterator_pair_constructor): Likewise.
(stack(InputIterator, InputIterator)): Likewise.
(stack(InputIterator, InputIterator, const Alloc&)): Likewise.
* include/std/version (__cpp_lib_adaptor_iterator_pair_constructor):
Define.
* testsuite/23_containers/queue/cons_from_iters.cc: New test.
* testsuite/23_containers/stack/cons_from_iters.cc: New test.
Diffstat (limited to 'libstdc++-v3/include/bits/stl_queue.h')
-rw-r--r-- | libstdc++-v3/include/bits/stl_queue.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h index 4519f9f2fec..ccd1122f848 100644 --- a/libstdc++-v3/include/bits/stl_queue.h +++ b/libstdc++-v3/include/bits/stl_queue.h @@ -194,6 +194,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Alloc, typename _Requires = _Uses<_Alloc>> queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) { } + +#if __cplusplus > 202002L +#define __cpp_lib_adaptor_iterator_pair_constructor 202100L + + template<typename _InputIterator, + typename = _RequireInputIter<_InputIterator>> + queue(_InputIterator __first, _InputIterator __last) + : c(__first, __last) { } + + template<typename _InputIterator, typename _Alloc, + typename = _RequireInputIter<_InputIterator>, + typename = _Uses<_Alloc>> + queue(_InputIterator __first, _InputIterator __last, const _Alloc& __a) + : c(__first, __last, __a) { } +#endif #endif /** @@ -331,6 +346,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename = _RequireAllocator<_Allocator>> queue(_Container, _Allocator) -> queue<typename _Container::value_type, _Container>; + +#ifdef __cpp_lib_adaptor_iterator_pair_constructor + template<typename _InputIterator, + typename _ValT + = typename iterator_traits<_InputIterator>::value_type, + typename = _RequireInputIter<_InputIterator>> + queue(_InputIterator, _InputIterator) -> queue<_ValT>; + + template<typename _InputIterator, typename _Allocator, + typename _ValT + = typename iterator_traits<_InputIterator>::value_type, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + queue(_InputIterator, _InputIterator, _Allocator) + -> queue<_ValT, deque<_ValT, _Allocator>>; +#endif #endif /** |