Failed to specialize function template

Posted by citizencane on Stack Overflow See other posts from Stack Overflow or by citizencane
Published on 2011-01-07T22:42:56Z Indexed on 2011/01/07 23:53 UTC
Read the original article Hit count: 187

This is homework, although it's already submitted with a different approach.

I'm getting the following from Visual Studio 2008

error C2893: Failed to specialize function template 'void std::sort(_RanIt,_RanIt,_Pr)'

The code is as follows

main.cpp
    Database<> db; 
    db.loadDatabase();
    db.sortDatabase(sort_by_title());  

Database.cpp
void Database<C>::sortDatabase(const sort_by &s) { 
    std::sort(db_.begin(), db_.end(), s); 
}

And the function objects are defined as

struct sort_by : public std::binary_function<const Media *, const Media *, bool> { 
    virtual bool operator()(const Media *l, const Media *r) const = 0;
};

struct sort_by_title : public sort_by {
    bool operator()(const Media *l, const Media *r) const { ... }
};
...

What's the cure here?

[Edit] Sorry, maybe I should have made the inheritance clear

template <typename C = std::vector<Media *> >
class Database : public IDatabase<C> 

[/Edit]

© Stack Overflow or respective owner

Related posts about c++

Related posts about inheritance