
13 Feb
2006
13 Feb
'06
7:08 p.m.
Marc Mutz wrote: <snip>
I was wondering why any_cast doesn't return a reference (as boost::get does for boost::variant). To me, it seems to make little sense to supply a any_cast overload with argument any& in addition to const any &, for return-by-value. It also needlessly invokes T's copy ctor, which esp bad if that one throws.
<snip> According to the documentation of boost::any_cast<T>, "if T is a reference to (possibly const qualified) ValueType, it [boost::any_cast] returns a reference to the held value." -delfin