Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your BaseVisitor does nothing for you, other than allowing arbitrary visitees to delete the visitor. Instead, you want to have a base class for the visitor which provides <em>all</em> of the different <code>accept</code> functions that could be called on it, and for the <code>Visitable</code> to accept this visitor.</p> <p>To do this, you could use a <a href="http://books.google.co.uk/books?id=aJ1av7UFBPwC&amp;lpg=PA52&amp;vq=type%20list&amp;pg=PA51#v=onepage&amp;q&amp;f=false" rel="noreferrer">type list</a> to define the types the visitor can accept, have a base visitee class which takes the type list, and add the type list as a parameter to your visitee implementation.</p> <p>sketch of example:</p> <pre><code>// assuming a typelist has typedefs first and second and a // type 'empty' representing end of type list template&lt;typename Types&gt; class Visitor : public Visitor&lt;Types::second&gt; { public: // visitor has a visit function for each type in Types virtual void visit(typename Types::first&amp; visitable) = 0; }; template&lt;&gt; class Visitor&lt;empty&gt; { }; template&lt;typename Types&gt; class Visitable{ public: // base accepts a visitor which can visit any type in Types virtual void accept(Visitor&lt;Types&gt;&amp; visitor) = 0; }; template&lt;typename Derived, typename Types&gt; class VisitableImpl : public Visitable&lt;Types&gt; { public: // impl calls specific visit function virtual void accept(Visitor&lt;Types&gt;&amp; visitor) override { visitor.visit(static_cast&lt;Derived&amp;&gt;(*this)); } }; </code></pre>
    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.
    2. VO
      singulars
      1. This table or related slice is empty.
    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