Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-04-24 16:49:05


"Itay" <itay_maman_at_[hidden]> wrote in message
news:aa746t$3gm$1_at_main.gmane.org...
> That's true. Any's visitor does not meet the textbook's requirements for a
> visitor class. Nonetheless it does have a 'visitorish' quality. Hence,
I'll
> try to outline the requirements for a boost::any semi-visitor:
[snip]

Note that (a) you define the requirements yourself (b) you call visitor
something that's not a visitor.

[snip]
> Parameterizing boost::any on the type of the visitor seems like a
reasonable
> compromise. (imposed by (1))

Given the self-imposed requirement, well, there's not much implementation
flexibility out there for grabs :o). I believe that's not a reasonable
compromise.

[snip]
> By all means, boost::any is not a usual class, so its visitor is a bit
> eccentric, as well. Nonetheless, even when visiting anys, the concrete
> functionality is defined by a (statically typed) policy. I believe that,
for
> most practical purposes, this is an acceptable degree of freedom.

The any class cloaks a polymorphic type. The cloaked polymorphic type should
have a virtual function (actually, two) that enables visitation. That's as
simple as it goes, and it makes transition from a closed class to an open
class. I don't see how any being a unusual class implies that it must have a
severely restricted visitor. I think the idiom you describe is unusable. You
do need more visitors for a given type, otherwise you don't care much about
visitation.

Andrei


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk