This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: swap does not compile


Gabriel Dos Reis <gdr@integrable-solutions.net> writes:

| larsbj@gullik.net (Lars Gullik Bjønnes) writes:
>
| | I suddenly began to see this with gcc 3.4.
| | Can others reproduce this as well? 3.3.2 has no problem with it.
| | 
| | #include <vector>
| | 
| | using std::swap;
| | 
| | int main() 
| | {
| | 	size_t a = 1;
| |         size_t b = 2;
| | 	swap(a, b);
| | }
| | 
| | 
| | g++ -o swap swap.C
| | swap.C: In function `int main()':
| | swap.C:14: error: no matching function for call to `swap(size_t&, size_t&)'
>
| Your program is in error.  The general std::swap is not supposed to be
| found in <vector>.   #include <algorithm>

libstdc++ includes stl_algobase.h from vector.

including <algorithm> makes no difference. (I just left it out to make
the testcase smaller.)

OTOH if I remove <vector> then it compiles just fine.


#include <vector>
#include <algorithm>

using std::swap;

int main() 
{
	size_t a = 1;
        size_t b = 2;
	swap(a, b);
}
swap.C: In function `int main()':
swap.C:10: error: no matching function for call to `swap(size_t&, size_t&)'



-- 
	Lgb


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]