|
-
January 28th, 2009, 11:42 PM
#1
[RESOLVED] Declara object type based on run time template parameter
Hello to all expert C++ programmer,
Code:
template <typename T, class edgeType = edge>
class graph
{
public:
/*
shared_ptr's template parameter is object
and not pointer to object
*/
typedef boost::shared_ptr<vertex<T> >
vertexPtr;
private:
std::vector<vertexPtr> allVertex;
I want that when different type of edgeType is supplied, then i want instantiated different type of vertexPtr.
I have two type of edgeType, one is edge(undirected) and arcs(Directed).
Whenever user supplied, graph<int, arcs> DAG;, then in the
Code:
typedef boost::shared_ptr<arcs> arcsPtr;
typedef boost::shared_ptr<vertex<T, arcsPtr> > vertexPtr;
should have arcsPtr.
Then, if user graph<int> supplied this, then default vertexPtr should be used.
I hope this make sense to you all.
Traits or CRTP or any design patterns is greatly appreciated by me.
The purpose of this question is to declare a graph class template that works with directed and undirected class based on template parameter.
graph<int> grp -- Undirected;
graph(int, arcs> -- directed;
Thanks for your help.
Thanks for your help.
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
|