Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Variant: Passing visitor as a functionargument
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-09-05 20:18:36


On Fri, Sep 4, 2009 at 12:54 PM, Hawkes
Steve-FSH016<Steve.Hawkes_at_[hidden]> wrote:
>> >    void  visit(boost::static_visitor<> const& visitor)
>> >    {
>> >        BOOST_FOREACH(Attr attr, i_attrList)
>> >        {
>> >            boost::apply_visitor(visitor, attr);
>> >        }
>> >    }
>
>> Just for note, but considering that you are asking for a static_vistor
>> directly, and you create a visitor by using the CRTP, this shows that
>> you might want to learn a little bit more about how C++ handles classes
>> before delving into too much more.
>
> Could you explain what you mean? If by CRTP you mean the "curiously
> recurring template pattern," how does that apply here? The template
> parameter for static_visitor is its return type, not the type of the
> derived visitor. What specifically should I be focusing on learning
> more about here?

Er, right, it is not using it, brain-fart...

Regardless, you need a fully declared type, void
visit(boost::static_visitor<> const& visitor) will error as you saw.
You need to templatize it as the post above mine shows:
template<class Visitor> void visit(Visitor visitor)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net