Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2004-12-08 09:55:26


From: "Yuval Ronen" <ronen_yuval_at_[hidden]>
>
> Wouldn't it be nicer if class any will have a member method like:
>
> template <typename T>
> T get() const;
>
> or maybe even:
>
> template <typename T>
> const T& get() const;
> template <typename T>
> T& get();

So you'd prefer writing this:

   boost::any<...> a(...);
   int i(a.template get<int>());

to this?

   boost::any<...> a(...);
   int i(any_cast<int>(a));

The latter has the advantage of looking just like static_cast et
al, avoiding the ugly template qualification of the member
function invocation, and being shorter.

I think the current approach is better.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk