help



hi
i am a freshmen, i have a question about c++ stl.

first, i defined a struct PtrChannelExist and two functions:
SearchNodePtr isExistNodePtr

secondly, when I compile my project ver1.0 by VC6.0 in the
platform WindowXP.

the compiler indicated all is OK.

struct PtrChannelExist:
public binary_function<CChannel*,long,bool>{
bool operator()(const CChannel* lhs,const long rhs)const
{
return (lhs->m_lExternalChannelID) == rhs;
}
};

inline
channelPtrIt SearchNodePtr(ChannelPtrContainer& container,const long&
nodeID)
{
return
find_if(container.begin(),container.end(),bind2nd(PtrChannelExist(),nodeID));
}

inline
BOOL isExistNodePtr(const long& nodeID,ChannelPtrContainer& container)
{
BOOL isOk = false;
if (CheckNode(nodeID))
{
channelPtrIt it = SearchNodePtr(container,nodeID);
if ((it != container.end()) && (*it)->m_bChannelState)
isOk = true;
}

return isOk;
}


but , after i updated the struct PtrChannelExist and two
functions:
SearchNodePtr , the compiler indicated something were wrong.


template <typename OP>
class Xbinder2nd:
public unary_function<typename OP::first_argument_type,
typename OP::result_type>
{
protected:
OP _op;
typename OP::second_argument_type _n;

public:
Xbinder2nd(const OP& op,const typename OP::second_argument_type& n)
:_op(op),_n(n) {}

typename OP::result_type //return type
operator()(const typename OP::first_argument_type& x)const
{
return _op((*x)->m_lExternalChannelID,_n);
}
};

template<typename OP, typename T>
inline
Xbinder2nd<OP> Xbind2nd(const OP& op,const T& n)
{
typedef typename OP::second_argument_type OpSat;
return Xbinder2nd<OP>(op,(OpSat)n);
}

template<typename elementT,typename T>
inline
T::iterator SearchNodePtr(T container,elementT nodeID)
{
T::iterator findIt =
find_if(container.begin(),container.end(),bind2nd(equal<T::iterator,long>(),nodeID));
return findIt;
}

template<typename elementT,typename T>
inline
BOOL isExistNodePtr(elementT& nodeID,T& container)
{
return ((SearchNodePointer(container,nodeID) != container.end()) ?
true : false);
}


these are error message:

...\struct.h(266) : error C2780: 'bool __cdecl
std::equal(_II1,_II1,_II2,_Pr)' : expects 4 arguments - 0 provided
d:\program files\microsoft visual studio\vc98\include\xutility(33) :
see declaration of 'equal' comultiplayer\struct.h(274) : see
reference to function template instantiation 'class CChannel **__cdecl
SearchNodePointer(class std::vector<class CChannel *,class
std::allocator<class
CChannel *> >,long) ' being compiled
comultiplayer\struct.h(266) : error C2780: 'bool __cdecl
std::equal(_II1,_II1,_II2)' : expects 3 arguments - 0 provided
d:\program files\microsoft visual studio\vc98\include
\xutility(29) : see declaration of 'equal'
\comultiplayer\struct.h(274) : see reference to function
template instantiation 'class CChannel **__cdecl
SearchNodePointer(class std::vector<class CChannel *,class
std::allocator<class
CChannel *> >,long) ' being compiled

.



Relevant Pages

  • Re: RAD Studio Roadmap Updated
    ... Strict private and strict protected provide a means for the compiler ... It will comply according to the specification (of the inline ... the exposure of the implementation details is CRITICAL ...
    (borland.public.delphi.non-technical)
  • Re: OT: C++ overloading operators
    ... way before complex numbers were part of the STL. ... I used the INLINE directive for these trivial functions. ... A compiler can not do inlining without access to the source code. ...
    (comp.dsp)
  • Re: HLA
    ... inline assembler for that compiler. ... different beast from a standalone assembler and IMHO, HLA is most ... It could be added to almost any C compiler without problems... ... then you're no longer programming in the standard form of the ...
    (alt.lang.asm)
  • Re: Inline Functions?
    ... an inline function is a programming language ... that is, it suggests that the compiler ... so the complete body of function func() should actually be placed from ...
    (comp.lang.c)
  • Re: introspection in SML
    ... inline and notinline declarations, and compiler macros. ... still sometimes do it, but with a compiler like MLton, I don't have ... noticed that it did fewer calls to arbitrary precision ...
    (comp.lang.functional)

Loading