Boost logo

Boost :

From: Dan Nuffer (dnuffer_at_[hidden])
Date: 2000-11-03 13:47:38


Darin Adler wrote:
>
> on 11/3/00 10:10 AM, Dan Nuffer at dnuffer_at_[hidden] wrote:
>
> > Also, I am using gcc 2.95.2 on Caldera OpenLinux 2.4 and any_cast wouldn't
> > compile. gcc was giving the following warning:
> >
> > src/tokenizer/any.hpp:179: parse error before `>'
> >
> > It didn't like the to_ptr<ValueType> for some strange reason. It
> > normally accepts this syntax...
> > To get around the problem I had to add a little template helper:
> >
> > template <typename ValueType>
> > const ValueType * to_ptr_helper( ValueType* ) const
> > {
> > return const_cast<any *>(this)->to_ptr<ValueType>();
> > }
>
> If we use this workaround, I recommend adding the "inline" keyword to this
> function template.
>
> -- Darin

I guess I wasn't clear on where I added to_ptr_helper. I added it as a
template member function of the any class. I don't know if this is the
best way of doing it or not, as it pollutes any's interface, but at
least it compiles!

I just tried making it a separate template function like this:
 template <typename ValueType>
 inline const ValueType * to_ptr_helper( const any * operand, ValueType*
)
 {
  return const_cast<any *>(operand)->to_ptr<ValueType>();
 }

But unfortunately g++ gave me the same error I experienced before:
src/tokenizer/Any.h:168: parse error before `>'

--Dan Nuffer


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