Boost logo

Boost Users :

Subject: Re: [Boost-users] boost any questions and praise
From: Peter Foelsche (foelsche_at_[hidden])
Date: 2010-02-08 16:47:40


"Pete Bartlett" <pete_at_[hidden]> wrote in message
news:945E24FD89F64B3F99A97FF3DF871D2F_at_HBEKER.com...

> I only compiled and ran the code in my head but I think it is quite
> dangerous. Isn't the only reason it compiles is because
> operator<<(ostream&,any const&) is recursive in the case that the any
> holds
> a non-streamable type? E.g. the C in your case. Thus, if the user
> accidentally tries to stream a non-streamable type he hard-crashes his
> program by blowing the stack... and because it is an any he has no
> means of
> knowing for sure if the contents are streamable at instantiation
> time. He
> has to "trust to luck". The OP might not like the term "type-safe"
> but here
> the downsides of non-type safety are showing themselves up!
>
> Of course a more advanced implementation might go down a
> has_operator_stream
> metafunction route. But then you are getting well away from the
> spirit of
> Any and towards that of Adobe.Poly as another posted mentioned.

I agree.
I've made boost::any a template -- so that it get's passed a callback type.
Is this according to your standards?
I think boost::any without any way to apply something to it, is quite
useless.

Peter





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