operator.rst 682 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
.. operator.rst

############################
Build a graph with operators
############################

This section illustrates the use of C++ operators to simplify the
building of graphs.

Several C++ operators are overloaded to simplify graph construction.
For example, the following:

13
.. literalinclude:: ../../../../examples/abc/abc.cpp
14 15 16 17 18
   :language: cpp
   :lines: 32-32

can be simplified to:	   

19
.. literalinclude:: ../../../../examples/abc_operator/abc_operator.cpp
20 21 22 23 24 25
   :language: cpp
   :lines: 31

The expression ``a + b`` is equivalent to
``std::make_shared<op::Add>(a, b)`` and the ``*`` operator similarly
returns ``std::make_shared<op::Multiply>`` to its arguments.