|
Boost Users : |
Subject: Re: [Boost-users] boost any questions and praise
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-01-31 19:50:29
On Sun, Jan 31, 2010 at 10:09 AM, Alan Tennant <alan2here_at_[hidden]> wrote:
> and std::vector is even more type safe, but even less useful.
>
> I think the term "type safe" having the word "safe" in it was created by
> it's supporters, it's as biased as a term as "strongly typed".
>
> If some code is getting an object then that code already knows why it is
> requesting that object and what it will do with the object, what methods it
> would make sense to call on the object, what methods might not be available
> and the such.
>
> If there were no recursive functions, or objects, no flow control like "for"
> or "while" available, nothing like a code type either that would allow you
> to abstract a loop, then your program would be guaranteed "loop safe" and
> "lockup safe".
>
> Maybe there should be a fixed number of types, like in the original C with
> no objects, then it would be totally safe.
Variant is superior to Any in a few ways:
Speed: Variant does a switch lookup, very fast, inlined visitors.
Any requires RTTI which has a *VERY* slow lookup, plus a virtual
function call.
Memory: Variant does not allocate memory unless your variant is
recursive, Any tends to allocate memory in general.
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