From c54171fee6142ce7ad3d0ae20a26f68ce053fd85 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 1 Nov 2007 01:40:56 +0000 Subject: [PATCH] stl_queue.h (queue<>::push(value_type&&)): Replace with "emplace" version per DR 756. 2007-10-31 Paolo Carlini * include/bits/stl_queue.h (queue<>::push(value_type&&)): Replace with "emplace" version per DR 756. (priority_queue<>::push(value_type&&)): Likewise. * include/bits/stl_stack.h (stack<>::push(value_type&&)): Likewise. From-SVN: r129814 --- libstdc++-v3/ChangeLog | 7 +++++++ libstdc++-v3/include/bits/stl_queue.h | 30 +++++++++++++++------------ libstdc++-v3/include/bits/stl_stack.h | 12 ++++++----- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2b783daf8bb7..f2ea755669a9 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2007-10-31 Paolo Carlini + + * include/bits/stl_queue.h (queue<>::push(value_type&&)): Replace + with "emplace" version per DR 756. + (priority_queue<>::push(value_type&&)): Likewise. + * include/bits/stl_stack.h (stack<>::push(value_type&&)): Likewise. + 2007-10-30 Paolo Carlini * include/tr1_impl/random (uniform_int<>:: diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h index d772c0360acf..4ab3c46c0b89 100644 --- a/libstdc++-v3/include/bits/stl_queue.h +++ b/libstdc++-v3/include/bits/stl_queue.h @@ -220,14 +220,16 @@ _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); } - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - void - push(value_type&& __x) - { c.push_back(std::move(__x)); } +#else + // NB: DR 756. + template + void + push(_Args&&... __args) + { c.push_back(std::forward<_Args>(__args)...); } #endif /** @@ -507,20 +509,22 @@ _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); } - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - void - push(value_type&& __x) - { - c.push_back(std::move(__x)); - std::push_heap(c.begin(), c.end(), comp); - } +#else + // NB: DR 756. + template + void + push(_Args&&... __args) + { + c.push_back(std::forward<_Args>(__args)...); + std::push_heap(c.begin(), c.end(), comp); + } #endif /** diff --git a/libstdc++-v3/include/bits/stl_stack.h b/libstdc++-v3/include/bits/stl_stack.h index 8af33970f1d3..932388a7a68b 100644 --- a/libstdc++-v3/include/bits/stl_stack.h +++ b/libstdc++-v3/include/bits/stl_stack.h @@ -184,14 +184,16 @@ _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); } - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - void - push(value_type&& __x) - { c.push_back(std::move(__x)); } +#else + // NB: DR 756. + template + void + push(_Args&&... __args) + { c.push_back(std::forward<_Args>(__args)...); } #endif /** -- 2.47.2