Boost logo

Boost Users :

From: Marc Mutz (marc_at_[hidden])
Date: 2006-02-13 13:34:49


Hi,

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.

Both observations considered, I think the implementation should rather be
  template <typename T> T & any_cast( any & );
  template <typename T> const T & any_cast( const any & );
  template <typename T> T * any_cast( any * );
  template <typename T> const T * any_cast( const any * );
Don't you agree?

Thanks,
Marc

-- 
Marc Mutz -- marc_at_[hidden], mutz_at_[hidden]
phone: +49 521 521 45 45; mobile: +47 45 27 38 95
Klarälvdalens Datakonsult AB, Platform-independent software solutions

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