Re: help



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
.



Relevant Pages


Loading