Version 1 (modified by 15 years ago) ( diff ) | ,
---|
An early prototype of the design proposed to simply (publicly) inherit the adjacency_list
class like so:
namespace boost { template <class VL, class EL, class OEL, class VP, class EP, class GP> class undirected_graph : public adjacency_list<OEL, VL, undirectedS, VP, EP, GP, EL> { }; }
Rationale
The rationale with for this approach to the implementation is simply "minimal work, maximal payoff". Potentially, this would implement half my proposal in a single line of code - or rather 2 lines including the directed graph class.
Remarks
Obviously, this probably the simplest implementation possible with as much reuse as possible. In this strategy, I wouldn't even have to implement any of the requirement methods since graphs are always passed by reference, we can let the inheritance handle this for us. The problem with this approach is that if we ever decide to put members into this class, we can run the risk of object-slicing due to blind reuse of methods that I didn't write. While the alure of a one-line implementation is strong, we should probably defer to practical experience and good advice (in the form of C++ Coding Standards: 101 Rules Guidelines and Best Practices by Sutter and Alexandrescu). I'm not overloading virtual functions, accessing protected members, and I'm pretty sure adjacency_list<>
wasn't intended for inheritance.