Re: help
- From: "Tom Widmer [VC++ MVP]" <tom_usenet@xxxxxxxxxxx>
- Date: Tue, 27 Mar 2007 16:32:13 +0100
paultwa2006@xxxxxxxxx wrote:
now , i update my project detail below;
template<typename T1, typename T2>
struct ChannelExist:
public binary_function<T1,T2,bool>{
bool operator()(const T1& lhs,const T2& rhs)const
{
return (lhs->m_lExternalChannelID) == rhs;
}
};
Why make that a template? Do you have other types with a member called m_lExternalChannelID?
template<typename elementT,typename T>
inline
T::iterator SearchNodePointer(T container,elementT nodeID)
{
//T::iterator findIt =
find_if(container.begin(),container.end(),bind2nd(equal<T::iterator,long>(),nodeID));
T::iterator findIt =
find_if(container.begin(),container.end(),bind2nd(ChannelExist<T::iterator,long>(),nodeID));
return findIt;
On that line, you should have T::value_type, not T::iterator. Again, the utility of making that a template is limited.
but , the compiler send me error message:
:\program files\microsoft visual studio\vc98\include\algorithm(50) :
error C2664: '()' : cannot convert parameter 1 from 'class CChannel *'
to 'class CChannel **const & '
Reason: cannot convert from 'class CChannel *' to 'class
CChannel **const '
why?
Algorithms don't pass iterators onto your functors, but the values those iterators point to.
Note that your code is missing the keyword "typename" in a lot of places. If you upgrade to a better compiler (e.g. VC8), you'll get errors about this.
Tom
.
- Follow-Ups:
- Re: help
- From: paultwa2006
- Re: help
- Prev by Date: Re: Last valid element in a vector
- Next by Date: Re: help
- Previous by thread: Re: help
- Next by thread: Re: help
- Index(es):
Relevant Pages
|
Loading