This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/43917] [C++0x] std::swap not working
- From: "navin dot kumar at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Apr 2010 17:43:08 -0000
- Subject: [Bug libstdc++/43917] [C++0x] std::swap not working
- References: <bug-43917-17658@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from navin dot kumar at gmail dot com 2010-04-28 17:43 -------
Are you compiling with -std=c++0x or without? It compiles fine without the
-std=c++0x flag. The issue is when it is supplied.
Look at line 134 of include/c++/4.5.0/bits/stl_pair.h; inside a #ifdef
__GXX_EXPERIMENTAL_CXX0X__ tag there is the following function:
void
swap(pair&& __p)
{
using std::swap;
swap(first, __p.first);
swap(second, __p.second);
}
The compiler error stems from trying to pass a pair l-value reference to
pair&&.
Here's the compiler error with line numbers:
include/c++/4.5.0/bits/stl_pair.h: In function ?void std::swap(std::pair<_T1,
_T2>&, std::pair<_T1, _T2>&) [with _T1 = std::basic_string<char>, _T2 =
std::basic_string<char>]?:
test.cpp:8:19: instantiated from here
include/c++/4.5.0/bits/stl_pair.h:187:7: error: cannot bind
?std::pair<std::basic_string<char>, std::basic_string<char> >? lvalue to
?std::pair<std::basic_string<char>, std::basic_string<char> >&&?
include/c++/4.5.0/bits/stl_pair.h:134:7: error: initializing argument 1 of
?void std::pair<_T1, _T2>::swap(std::pair<_T1, _T2>&&) [with _T1 =
std::basic_string<char>, _T2 = std::basic_string<char>, std::pair<_T1, _T2> =
std::pair<std::basic_string<char>, std::basic_string<char> >]?
--
navin dot kumar at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|WORKSFORME |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43917