|
-
April 19th, 2005, 11:35 AM
#1
Using std::sort on vector of pointers to objects
Hello again,
I would like to sort an std::vector containing pointers to SampleInCache objects, using the std::sort algorithm. But since the vector contains no objects, but pointers, I can not do that by simply overloading the <-operator of my SampleInCache class.
I tried this :
//adding this to SampleInCache.h
template <>
struct std::greater
{
bool operator()(const SampleInCache* leftVal, const SampleInCache* rightVal) const
{
//The sorting is actually more complex,
//but I first tried sorting only based on the last_time_used member of SampleInCache class
return leftVal->last_time_used < rightVal->last_time_used;
}
};
But then I get this error :
"error C2913: explicit specialization; 'std::greater' is not a specialization of a class template"
Does anyone see what I did wrong ?
Greetings,
Joanna
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|