I want to build a directed graph in C ++ 11 at compile time.
Example: I have some threads and queues and you want to create:
+-------+ +---------+ +-------+
| f_gen | -> QGen -> | f_check | -> QOut -> | f_out |
+-------+ +---------+ ^ +-------+
| |
\|/ |
| |
QProc |
| |
\|/ |
| |
+-----------+ |
| f_process | /
+-----------+
Note that this is just an example: a solution should handle oriented graphs of each node / edge type.
I want to write this, maybe as:
make_directed_graph<Queue, Thread>(
{
{ 0, std::string, 100 },
{ 1, int, 250 },
{ 2, std::string, 500 }
},
{
{ f_gen, 5, {}, { qref(0) } },
{ f_check, 30, { qref(0) }, { qref(1), qref(2) }},
{ f_process, 75, { qref(1) }, { qref(2) }},
{ f_out, 12, { qref(2) }, {} }
});
Please note that this is just an idea - any other opportunity to record it is good for me.
I managed to implement a function make_tree. It can be used as
make_tree< arexp, int >(
{ '+', { 1, 2, { '*', { 3, 4, 5 } } } } )
There is one big difference: nodes and edges can be created "on fly '- there is no need to refer to any existing one.
- /
/, . :
( ).
: