Boost logo

Boost :

From: Jesse Jones (jejones_at_[hidden])
Date: 2000-08-31 15:23:43

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

Most of the time you're probably right, but it does introduce a hole in the
type system. For example if someone is transitioning code from using
void*'s to any they might run into trouble.

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

Yeah, supporting the conversion and empty is a bit silly. But if you have
empty you don't need the conversion operator. :-)

>>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 :-)

Sure it does. You can remove two methods and 14 lines of code. Not a huge
savings, but the class is small enough that this does make a difference.

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

Providing three ways to get at the value seemed a bit excessive.

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

Hmm, I see your point.

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

get isn't clumsy in this case. any contains a single value and if you want
to access it you call get. What could be simpler? copy_to does convey a bit
more information, but clients will rarely care about the details of how the
value gets returned.

  -- Jesse

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