L
lok
i have a class:
template <class T1, class T2>
class CPairMapping {
public:
typedef std:air<T1, T2> ValuePair_t;
typedef std::vector<ValuePair_t> ValueList_t;
typedef std::binary_function< ValuePair_t, ValuePair_t, bool> ValuePair_IsLess;
void SortAscend(const ValuePair_IsLess& isLess_) {
std::sort(Map.begin(), Map.end(), isLess_);
}
// skip other funciton like add,delete,lookup...
protected:
ValueList_t Map;
};
i want to sort the Map with a functor supplied by the caller of SortAscend()
i created a functor:
typedef COne2ManyMapping<int, int> INT2INTMap;
class INT2INTMap_IsLess: public INT2INTMap::ValuePair_IsLess {
public:
bool operator() (INT2INTMap::ValuePair_t lhs_,INT2INTMap::ValuePair_t rhs_)
{
return true;
}
};
up to now, no compile or link error
but if i call the SortAscend loke this:
INT2INTMap a;
a.AddEntry(1, 2);
a.AddEntry(3, 4);
a.SortAscend( INT2INTMap_IsLess() );
my vc++ 6.0 compiler reported:
error C2064: term does not evaluate to a function
see reference to function template instantiation '
void __cdecl std::_Unguarded_insert(
struct std:air<int,int> *,
struct std:air<int,int>,
struct std::binary_function<
struct std:air<int,int>,
)
' being compiled
what is the problem ?
thx
template <class T1, class T2>
class CPairMapping {
public:
typedef std:air<T1, T2> ValuePair_t;
typedef std::vector<ValuePair_t> ValueList_t;
typedef std::binary_function< ValuePair_t, ValuePair_t, bool> ValuePair_IsLess;
void SortAscend(const ValuePair_IsLess& isLess_) {
std::sort(Map.begin(), Map.end(), isLess_);
}
// skip other funciton like add,delete,lookup...
protected:
ValueList_t Map;
};
i want to sort the Map with a functor supplied by the caller of SortAscend()
i created a functor:
typedef COne2ManyMapping<int, int> INT2INTMap;
class INT2INTMap_IsLess: public INT2INTMap::ValuePair_IsLess {
public:
bool operator() (INT2INTMap::ValuePair_t lhs_,INT2INTMap::ValuePair_t rhs_)
{
return true;
}
};
up to now, no compile or link error
but if i call the SortAscend loke this:
INT2INTMap a;
a.AddEntry(1, 2);
a.AddEntry(3, 4);
a.SortAscend( INT2INTMap_IsLess() );
my vc++ 6.0 compiler reported:
error C2064: term does not evaluate to a function
see reference to function template instantiation '
void __cdecl std::_Unguarded_insert(
struct std:air<int,int> *,
struct std:air<int,int>,
struct std::binary_function<
struct std:air<int,int>,
)
' being compiled
what is the problem ?
thx