diff options
Diffstat (limited to 'libstdc++-v3/include/bits/stl_queue.h')
-rw-r--r-- | libstdc++-v3/include/bits/stl_queue.h | 145 |
1 files changed, 143 insertions, 2 deletions
diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h index 469f9ec17be..4ab3c46c0b8 100644 --- a/libstdc++-v3/include/bits/stl_queue.h +++ b/libstdc++-v3/include/bits/stl_queue.h @@ -131,8 +131,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std) /** * @brief Default constructor creates no elements. */ +#ifndef __GXX_EXPERIMENTAL_CXX0X__ explicit - queue(const _Sequence& __c = _Sequence()) : c(__c) {} + queue(const _Sequence& __c = _Sequence()) + : c(__c) { } +#else + explicit + queue(const _Sequence& __c) + : c(__c) { } + + explicit + queue(_Sequence&& __c = _Sequence()) + : c(std::move(__c)) { } + + queue(queue&& __q) + : c(std::move(__q.c)) { } + + queue& + operator=(queue&& __q) + { + c = std::move(__q.c); + return *this; + } +#endif /** * Returns true if the %queue is empty. @@ -199,9 +220,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * to it. The time complexity of the operation depends on the * underlying sequence. */ +#ifndef __GXX_EXPERIMENTAL_CXX0X__ void push(const value_type& __x) { c.push_back(__x); } +#else + // NB: DR 756. + template<typename... _Args> + void + push(_Args&&... __args) + { c.push_back(std::forward<_Args>(__args)...); } +#endif /** * @brief Removes first element. @@ -220,8 +249,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __glibcxx_requires_nonempty(); c.pop_front(); } - }; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + swap(queue&& __q) + { c.swap(__q.c); } +#endif + }; /** * @brief Queue equality comparison. @@ -281,6 +315,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) { return !(__x < __y); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp, typename _Seq> + inline void + swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y) + { __x.swap(__y); } + + template<typename _Tp, typename _Seq> + inline void + swap(queue<_Tp, _Seq>&& __x, queue<_Tp, _Seq>& __y) + { __x.swap(__y); } + + template<typename _Tp, typename _Seq> + inline void + swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>&& __y) + { __x.swap(__y); } +#endif + /** * @brief A standard container automatically sorting its contents. * @@ -346,11 +397,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std) /** * @brief Default constructor creates no elements. */ +#ifndef __GXX_EXPERIMENTAL_CXX0X__ explicit priority_queue(const _Compare& __x = _Compare(), const _Sequence& __s = _Sequence()) : c(__s), comp(__x) { std::make_heap(c.begin(), c.end(), comp); } +#else + explicit + priority_queue(const _Compare& __x, + const _Sequence& __s) + : c(__s), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + explicit + priority_queue(const _Compare& __x = _Compare(), + _Sequence&& __s = _Sequence()) + : c(std::move(__s)), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } +#endif /** * @brief Builds a %queue from a range. @@ -367,6 +432,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * documentation on @link s20_3_1_base functor base * classes@endlink. */ +#ifndef __GXX_EXPERIMENTAL_CXX0X__ template<typename _InputIterator> priority_queue(_InputIterator __first, _InputIterator __last, const _Compare& __x = _Compare(), @@ -377,6 +443,40 @@ _GLIBCXX_BEGIN_NAMESPACE(std) c.insert(c.end(), __first, __last); std::make_heap(c.begin(), c.end(), comp); } +#else + template<typename _InputIterator> + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x, + const _Sequence& __s) + : c(__s), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } + + template<typename _InputIterator> + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x = _Compare(), + _Sequence&& __s = _Sequence()) + : c(std::move(__s)), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } + + priority_queue(priority_queue&& __pq) + : c(std::move(__pq.c)), comp(std::move(__pq.comp)) { } + + priority_queue& + operator=(priority_queue&& __pq) + { + c = std::move(__pq.c); + comp = std::move(__pq.comp); + return *this; + } +#endif /** * Returns true if the %queue is empty. @@ -409,12 +509,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * The time complexity of the operation depends on the underlying * sequence. */ +#ifndef __GXX_EXPERIMENTAL_CXX0X__ void push(const value_type& __x) { c.push_back(__x); std::push_heap(c.begin(), c.end(), comp); } +#else + // NB: DR 756. + template<typename... _Args> + void + push(_Args&&... __args) + { + c.push_back(std::forward<_Args>(__args)...); + std::push_heap(c.begin(), c.end(), comp); + } +#endif /** * @brief Removes first element. @@ -434,10 +545,40 @@ _GLIBCXX_BEGIN_NAMESPACE(std) std::pop_heap(c.begin(), c.end(), comp); c.pop_back(); } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + swap(priority_queue&& __pq) + { + using std::swap; + c.swap(__pq.c); + swap(comp, __pq.comp); + } +#endif }; // No equality/comparison operators are provided for priority_queue. +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp, typename _Sequence, typename _Compare> + inline void + swap(priority_queue<_Tp, _Sequence, _Compare>& __x, + priority_queue<_Tp, _Sequence, _Compare>& __y) + { __x.swap(__y); } + + template<typename _Tp, typename _Sequence, typename _Compare> + inline void + swap(priority_queue<_Tp, _Sequence, _Compare>&& __x, + priority_queue<_Tp, _Sequence, _Compare>& __y) + { __x.swap(__y); } + + template<typename _Tp, typename _Sequence, typename _Compare> + inline void + swap(priority_queue<_Tp, _Sequence, _Compare>& __x, + priority_queue<_Tp, _Sequence, _Compare>&& __y) + { __x.swap(__y); } +#endif + _GLIBCXX_END_NAMESPACE #endif /* _STL_QUEUE_H */ |