Error C2535 With vector ("member function already defined")
I'm unable to compile the most trivial program using a vector with Visual
Studio 2003 (version 7.1.3008).
It worked fine with 6.0.
-------------------------------------
#include "StdAfx.h"
#include <vector>
class MyTest
{
public:
MyTest(void) {};
~MyTest(void) {};
};
static void func () {
std::vector<MyTest> myVec;
MyTest myTest;
myVec.push_back(myTest);
}
-------------------------------------
------ Build started: Project: VectorTest, Configuration: Debug Win32 ------
Compiling...
MyTest.cpp
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xmemory(87) :
error C2535: 'std::allocator<_Ty>::pointer
std::allocator<_Ty>::address(std::allocator<_Ty>::reference) const' : member
function already defined or declared
with
[
_Ty=const MyTest
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xmemory(81) : see declaration of
'std::allocator<_Ty>::address'
with
[
_Ty=const MyTest
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\memory(257) : see reference to class template instantiation
'std::allocator<_Ty>' being compiled
with
[
_Ty=const MyTest
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\vector(878) : see reference to function template
instantiation 'void
std::_Uninitialized_fill_n<std::vector<_Ty>::pointer,std::vector<_Ty>::size_type,_Ty,std::_Vector_val<_Ty,_Alloc>::_Alty>(_FwdIt,_Diff,const
_Tval &,_Alloc &)' being compiled
with
[
_Ty=MyTest,
_Alloc=std::allocator<MyTest>,
_FwdIt=std::vector<MyTest>::pointer,
_Diff=std::vector<MyTest>::size_type,
_Tval=MyTest
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\vector(877) : while compiling class-template member function
'std::vector<_Ty>::pointer
std::vector<_Ty>::_Ufill(std::vector<_Ty>::pointer,std::vector<_Ty>::size_type,const _Ty &)'
with
[
_Ty=MyTest
]
c:\Documents and Settings\sjohnson\My Documents\Visual Studio
Projects\AuthorizationService\VectorTest\MyTest.cpp(22) : see reference to
class template instantiation 'std::vector<_Ty>' being compiled
with
[
_Ty=MyTest
]
Build log was saved at "file://c:\Documents and Settings\sjohnson\My
Documents\Visual Studio
Projects\AuthorizationService\VectorTest\Debug\BuildLog.htm"
VectorTest - 1 error(s), 0 warning(s)
-------------------------------------