Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-11-07 11:18:44


In message <3A03121E.BFD6C878_at_[hidden]>, Dan Nuffer
<dnuffer_at_[hidden]> writes
>After fiddling around some more, I found an even better way to get g++
>to compile this.
>There is no need for to_ptr_helper, simply change any_cast like this:
>
> template<typename ValueType>
> ValueType any_cast(const any & operand)
> {
> const ValueType * result =
> operand.template to_ptr<ValueType>();
>
> if(!result)
> {
> throw bad_any_cast();
> }
>
> return *result;
> }
>
>Adding "template" in the middle of "operand.to_ptr" looks strange, but
>it's valid and helps g++ parse it correctly.

Thanks for this. I will document this under usage of to_ptr and in the
portability section. It's worth noting that this doesn't fix the problem
under MSVC :-(

Kevlin
____________________________________________________________

  Kevlin Henney phone: +44 117 942 2990
  Curbralan Limited mobile: +44 7801 073 508
  mailto:kevlin_at_[hidden] fax: +44 870 052 2289
  http://www.curbralan.com
____________________________________________________________


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