Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your example you could remove the new and delete by removing the <code>callback</code> class. This is just a Decorator on <code>callable_from_object</code> and <code>callable_from_object</code> that provides some syntactic sugar: automatically choosing the correct callable object to delegate to.</p> <p>However this sugar is nice and you will probably want to keep it. Also you will probably have to place the objects other callable objects on the heap anyway.</p> <p>To me the bigger question is why are you creating a callback library? If it is just to practice c++ then that is fine, but there are loads of exaples of these already:</p> <ul> <li><a href="http://www.boost.org/doc/html/function.html" rel="nofollow noreferrer">boost::function</a></li> <li><a href="http://www.boost.org/doc/html/signals.html" rel="nofollow noreferrer">boost::singnal and slots</a></li> <li><a href="http://doc.trolltech.com/signalsandslots.html" rel="nofollow noreferrer">QT signal and slots</a></li> </ul> <p>Why not use one these?</p> <p>From looking at your example if you keep on the path you are going your solution will converge towards boost::function without its flexibility. So why not use it? While I don't beleive that the boost developers are Gods they are very tallented engineers with an excellent peer review process that results in very stong libraries. I don't think most individuals or organisations can reinvent better libraries.</p> <p>If your concern is excessive memeory allocation and deallocation the solution is this case would probably be a custom allocator for the various callable subtypes. But again I prefer to allow other people to research these tecniques and use their libraries.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload