Boost logo

Boost :

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

"Itay" <itay_maman_at_[hidden]> wrote in message
> 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,
> try to outline the requirements for a boost::any semi-visitor:

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

> Parameterizing boost::any on the type of the visitor seems like a
> 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

> 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,
> 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


Boost list run by bdawes at, gregod at, cpdaniel at, john at