summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/stl_queue.h
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2017-01-10 17:30:20 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2017-01-10 17:30:20 +0000
commitd2e1d4b71387f5fbcf7198f05ddeb39e38b3d511 (patch)
treeeec6350cf193eac941b657624a89f5b22b96b405 /libstdc++-v3/include/bits/stl_queue.h
parent034afd02315485c0b548f6d5da2709057fb494cb (diff)
downloadgcc-d2e1d4b71387f5fbcf7198f05ddeb39e38b3d511.tar.gz
PR77528 add default constructors for container adaptors
PR libstdc++/77528 * include/bits/stl_queue.h (queue::c): Add default member initializer. (queue::queue()): Add constructor and define as defaulted. (queue::queue(_Sequence&&)): Remove default argument. (priority_queue::c, priority_queue::comp): Add default member initializers. (priority_queue::priority_queue()): Add constructor and define as defaulted. (priority_queue::priority_queue(const _Compare&, _Sequence&&)): Remove default argument for first parameter. * include/bits/stl_stack.h (stack::c): Add default member initializer. (stack::stack()): Add constructor and define as defaulted. (stack::stack(const _Sequence&)): Remove default argument. * testsuite/23_containers/priority_queue/requirements/ explicit_instantiation/1.cc: Test explicit instantiation with non-DefaultConstructible sequence. * testsuite/23_containers/priority_queue/77528.cc: New test. * testsuite/23_containers/priority_queue/requirements/ explicit_instantiation/1_c++0x.cc: Replace with 1_c++98.cc. * testsuite/23_containers/queue/77528.cc: New test. * testsuite/23_containers/queue/requirements/explicit_instantiation/ 1.cc: Test explicit instantiation with non-DefaultConstructible sequence. * testsuite/23_containers/queue/requirements/explicit_instantiation/ 1_c++0x.cc: Replace with 1_c++98.cc. * testsuite/23_containers/stack/77528.cc: New test. * testsuite/23_containers/stack/requirements/explicit_instantiation/ 1.cc: Test explicit instantiation with non-DefaultConstructible sequence. * testsuite/23_containers/stack/requirements/explicit_instantiation/ 1_c++0x.cc: Replace with 1_c++98.cc. From-SVN: r244278
Diffstat (limited to 'libstdc++-v3/include/bits/stl_queue.h')
-rw-r--r--libstdc++-v3/include/bits/stl_queue.h29
1 files changed, 21 insertions, 8 deletions
diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h
index 45eba09078d..6417b3067f6 100644
--- a/libstdc++-v3/include/bits/stl_queue.h
+++ b/libstdc++-v3/include/bits/stl_queue.h
@@ -124,15 +124,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _Sequence container_type;
protected:
- /**
- * 'c' is the underlying container. Maintainers wondering why
- * this isn't uglified as per style guidelines should note that
- * this name is specified in the standard, [23.2.3.1]. (Why?
- * Presumably for the same reason that it's protected instead
+ /* Maintainers wondering why this isn't uglified as per style
+ * guidelines should note that this name is specified in the standard,
+ * C++98 [23.2.3.1].
+ * (Why? Presumably for the same reason that it's protected instead
* of private: to allow derivation. But none of the other
* containers allow for derivation. Odd.)
*/
+ /// @c c is the underlying container.
+#if __cplusplus >= 201103L
+ _Sequence c{};
+#else
_Sequence c;
+#endif
public:
/**
@@ -143,12 +147,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
queue(const _Sequence& __c = _Sequence())
: c(__c) { }
#else
+ queue() = default;
+
explicit
queue(const _Sequence& __c)
: c(__c) { }
explicit
- queue(_Sequence&& __c = _Sequence())
+ queue(_Sequence&& __c)
: c(std::move(__c)) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
@@ -440,8 +446,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
protected:
// See queue::c for notes on these names.
- _Sequence c;
+#if __cplusplus >= 201103L
+ _Sequence c{};
+ _Compare comp{};
+#else
+ _Sequence c;
_Compare comp;
+#endif
public:
/**
@@ -454,6 +465,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: c(__s), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
#else
+ priority_queue() = default;
+
explicit
priority_queue(const _Compare& __x,
const _Sequence& __s)
@@ -461,7 +474,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ std::make_heap(c.begin(), c.end(), comp); }
explicit
- priority_queue(const _Compare& __x = _Compare(),
+ priority_queue(const _Compare& __x,
_Sequence&& __s = _Sequence())
: c(std::move(__s)), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }