Failed to specialize function template
- by citizencane
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]