Error : Visual 2005 is more C++ compliant and my projct doesn't compile

V

Vincent RICHOMME

Hi,

I found a project called ACF and that implemnts .NET classes into C++.
The issue come from the fact that it was developped under VS 2003
and under 2005 I get the following

c:\acf\src\corlib\acf\acfbase.h(364) : error C2299:
'Acf::RefPtr<T>::RefPtr' : behavior change: an explicit specialization
cannot be a copy constructor or copy assignment operator

template <class T> // T: reference types (object, interface)
class RefPtr
{
// Fields
private:
T* _p;

// Constructor & Destructor
public:
RefPtr() : _p(null)
{
}
RefPtr(T* p) : _p(p)
{
_AddRef();
}
// Templated version to allow pBase = pDerived
template <class U>
RefPtr(const RefPtr<U>& src) : _p((U*)src)
{
_AddRef();
}

// METHOD BELOW DO NOT COMPILE
template <>
RefPtr(const RefPtr<T>& src) : _p((T*)src)
{
_AddRef();
}

~RefPtr()
{
_Release();
}
.....
};


How can I fix that ?
 
M

mlimber

Vincent said:
Hi,

I found a project called ACF and that implemnts .NET classes into C++.
The issue come from the fact that it was developped under VS 2003
and under 2005 I get the following

c:\acf\src\corlib\acf\acfbase.h(364) : error C2299:
'Acf::RefPtr<T>::RefPtr' : behavior change: an explicit specialization
cannot be a copy constructor or copy assignment operator

template <class T> // T: reference types (object, interface)
class RefPtr
{
// Fields
private:
T* _p;

// Constructor & Destructor
public:
RefPtr() : _p(null)
{
}
RefPtr(T* p) : _p(p)
{
_AddRef();
}
// Templated version to allow pBase = pDerived
template <class U>
RefPtr(const RefPtr<U>& src) : _p((U*)src)
{
_AddRef();
}

// METHOD BELOW DO NOT COMPILE
template <>
RefPtr(const RefPtr<T>& src) : _p((T*)src)

Try just this (no "template<>"):

RefPtr(const RefPtr& src) : _p((T*)src)

{
_AddRef();
}

~RefPtr()
{
_Release();
}
....
};


How can I fix that ?

Cheers! --M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top