Discussion:
error C2039: 'swap' : is not a member of 'std'
(too old to reply)
Innersmile
2004-09-17 00:15:54 UTC
Permalink
Hi there,

I am always getting following errors when compiling my c++
program in Visual Studio 6.0:

--------------------Configuration: testgenreg - Win32
Release--------------------
Compiling...
testgenreg.cxx
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\vector(221) :
error C2039: 'swap' : is not a member of 'std'
C:\Program Files\Microsoft Visual
Studio\VC98\INCLUDE\vector(220) : while compiling class-template member
function 'void __thiscall std::vector<unsigned int,class
std::allocator<unsigned int> >::swap(class std::vector<unsigned
int,class std:
:allocator<unsigned int> > &)'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\vector(221) :
error C2660: 'swap' : function does not take 2 parameters
Error executing cl.exe.

testgenreg.exe - 6 error(s), 0 warning(s)

I am not using any STL class directly. I even minimize my main
program to int main(){return 0;}. But it still gives same errors.
However, since the code compiles under linux using g++. I guess
there must be something related to Visual Studio.

Any help is appreciated.
Simon Trew
2004-09-17 00:53:52 UTC
Permalink
(guess) try to include <algorithm> before <vector>

S.
Post by Innersmile
Hi there,
I am always getting following errors when compiling my c++
--------------------Configuration: testgenreg - Win32
Release--------------------
Compiling...
testgenreg.cxx
error C2039: 'swap' : is not a member of 'std'
Innersmile
2004-09-17 01:45:37 UTC
Permalink
thanks. this problems is solved
by removing the namespace std{}
which contains those standard headers.

I mean from

namespace std
{
#include <algorithm>
#include <vector>
// some other headers
}

=>

#include <algorithm>
#include <vector>
Post by Simon Trew
(guess) try to include <algorithm> before <vector>
S.
Post by Innersmile
Hi there,
I am always getting following errors when compiling my c++
--------------------Configuration: testgenreg - Win32
Release--------------------
Compiling...
testgenreg.cxx
error C2039: 'swap' : is not a member of 'std'
Steve McLellan
2004-09-17 11:02:22 UTC
Permalink
You should never re-namespace system headers (or any headers, really) - it
can cause all kinds of trouble, as you've seen. Other things may refer to
them with a fully qualified namespace (and not be able to find them), and
all sorts of bad stuff like that.

Steve
Post by Innersmile
thanks. this problems is solved
by removing the namespace std{}
which contains those standard headers.
I mean from
namespace std
{
#include <algorithm>
#include <vector>
// some other headers
}
=>
#include <algorithm>
#include <vector>
Post by Simon Trew
(guess) try to include <algorithm> before <vector>
S.
Post by Innersmile
Hi there,
I am always getting following errors when compiling my c++
--------------------Configuration: testgenreg - Win32
Release--------------------
Compiling...
testgenreg.cxx
error C2039: 'swap' : is not a member of 'std'
Simon Trew
2004-09-18 01:21:49 UTC
Permalink
If Innersmile's example was truly representative, the declarations of list
&c would be in namespace std::std.

S.

Loading...