Hi, I was trying to compile the following code using VC++ .NET. #include "stdafx.h" #include "boost/smart_ptr.hpp" int _tmain(int argc, _TCHAR* argv[]) { boost::shared_ptr<int> spc = new int(0); return 0; } I got the following error messages: c:\boost\smart_ptr.hpp(375) : error C2065: 'T' : undeclared identifier c:\boost\smart_ptr.hpp(375) : error C2687: cannot define a nested UDT of a template class out of line c:\boost\smart_ptr.hpp(375) : fatal error C1903: unable to recover from previous error(s); stopping compilation The offending code in smart_ptr.hpp is: template<typename T> struct less< boost::shared_ptr<T > > //..... LINE 375 : binary_function<boost::shared_ptr<T>, boost::shared_ptr<T>, bool> { bool operator()(const boost::shared_ptr<T>& a, const boost::shared_ptr<T>& b) const { return less<T*>()(a.get(),b.get()); } }; Can someone please tell me what is the problem? I was able to compile the same code using VC++ 6.0. Thanks. Ming
From: <cmwong@cedara.com>
Hi,
I was trying to compile the following code using VC++ .NET.
#include "stdafx.h" #include "boost/smart_ptr.hpp"
int _tmain(int argc, _TCHAR* argv[]) { boost::shared_ptr<int> spc = new int(0);
This should be boost::shared_ptr<int> spc(new int(0)); but it's not the source of the problem.
return 0; }
I got the following error messages:
c:\boost\smart_ptr.hpp(375) : error C2065: 'T' : undeclared identifier [...] The offending code in smart_ptr.hpp is: template<typename T> struct less< boost::shared_ptr<T > > //..... LINE 375 : binary_function<boost::shared_ptr<T>, boost::shared_ptr<T>, bool>
You are using an early version of Boost that doesn't know about VC++.NET (since it was released before the compiler.) Newer releases work with VC++ 7. If you don't want to upgrade Boost, try simply removing the less<> specialization from smart_ptr.hpp.
participants (2)
-
mwong <cmwong@cedara.com>
-
Peter Dimov