What kind of C++ abstraction works best in this [common] scenario?
// Pseudo code
abstraction FooBase {
init(name, options);
f(foo, bar): can;
g(bzr): haz;
};
Bar partially implements FooBase {
f(foo, bar) { return nullptr };
};
Car implements FooBase {
f(foo, bar) { return nullptr };
g(bzr) { return nullptr };
};
int main() {
auto o = FooBase(Bar, std::make_tuple(5,6,7));
o.g(5); // compile-time error: 'g' not implemented for 'Bar'
}
Note that the internal structure doesn't need to store any information except its initial options
and a cursor
object, so e.g.: a closure would suffice. I was thinking std::bind
and/or templates.
Aucun commentaire:
Enregistrer un commentaire