Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-08-31 03:57:38


In message <v03110700b5d34c54129f@[153.32.222.4]>, Jesse Jones
<jejones_at_[hidden]> writes
>>I have uploaded code, tests and docs for a variant value type,
>>boost::any, that holds values of arbitrary type:
>
>It's very cool. :-)

Thanks.

>A few comments:
>
>1) I really hate implicit conversion operators. I think it'd be better to
>use something like is_valid or empty instead.

In this case I would have said that the implicit conversion is benign,
so I don't see a problem. An older version of any supported empty, but
such duplication did not seem useful. I don't think the duplication buys
you anything, but if there are strong feelings on the list about it I
can put it back in.

>2) I think all the type_info stuff can be replaced with a single
>dynamic_cast in to_ptr.

Yes it can, but it doesn't buy you anything, which is why it is the way
it is :-)

>3) to_ptr seems like it would be better off as an internal method that
>clients shouldn't call.

Why? There's no other way that the client can actually get their hands
on the contained object, ie w/o copying it. Older versions of any had no
way of doing this at all, and that proved to be too strong a constraint.

>4) The name copy_to is a bit clumsy. get would seem pretty reasonable.

In older versions of any it was called get. However, get (as with set)
is a clumsy name member function name in almost all cases, so copy_to
was chosen >:->
____________________________________________________________

  Kevlin Henney phone: +44 117 942 2990
  Curbralan Ltd mobile: +44 7801 073 508
  kevlin_at_[hidden] fax: +44 870 052 2289
____________________________________________________________


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