This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/33930] [c++0x] ambiguous overload in std::stack::push() when using --std=cxx0x
- From: "pcarlini at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Oct 2007 00:07:02 -0000
- Subject: [Bug libstdc++/33930] [c++0x] ambiguous overload in std::stack::push() when using --std=cxx0x
- References: <bug-33930-14817@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from pcarlini at suse dot de 2007-10-31 00:07 -------
For concreteness would be something like the below (you can try it out, but
consider that the underlying sequence container "emplace" push_back are not
implemented yet, therefore expect only backward compatibility with C++03):
Index: stl_stack.h
===================================================================
--- stl_stack.h (revision 129768)
+++ stl_stack.h (working copy)
@@ -184,14 +184,16 @@
* 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
+ template<typename... _Args>
+ void
+ push(_Args&&... __args)
+ { c.push_back(std::forward<_Args>(__args)...); }
#endif
/**
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33930