|
Boost : |
From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-01-28 18:00:38
christopher diggins wrote:
> Hello all,
>
> I just realized that an empty BIL interface,
>
> BOOST_IDL_BEGIN(IAnything)
> BOOST_IDL_EMPTY(IAnything)
>
> has some common ground with:
>
> boost::any
>
> Where boost::any stores a copy of a value of practical any type for
> later extraction, IAnything can point to just about anything.
Yes, I noticed this just a few days ago ;-)
One can think of smart references as generalizations of any in which
- the ownership policy can vary; e.g., it could be reference-counted instead of
clone-on-copy
- the type of admissible objects can restricted using interfaces
- the syntax for binding is slightly different
For instance, a reference-counted any that can bind to anything is
shared_obj<IAnything>.
I'm thinking of adding a template boost::interfaces::any, which has cloning
semantics and uses the same syntax as any for binding, i.e., assignment and
construction from a const reference.
template<typename Interface = IAnything>
class any;
(I think boost::interfaces::null might be a better name for IAnything.)
However, maybe what is needed instead is just a policy-based smart reference.
Jonathan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk