Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2003-05-27 06:22:27


Marcelo E. Magallon wrote:

> I'm baffled. The compiler says:

>/usr/include/boost/math/quaternion.hpp: In function
>`boost::math::quaternion<T>
> boost::math::detail::quaternion_type_converter(const
> boost::math::quaternion<U>&) [with T = float, U = double]':
>/usr/include/boost/math/quaternion.hpp:866: instantiated from here
>/usr/include/boost/math/quaternion.hpp:449: error: `R_component_1'
>undeclared
> (first use this function)

I got the same sort of messages. It is even harder when GCC says:
   parse error before ';'!!!!

At least MS and Borland give better messages in this respect, e.g. missing
parenthesis.

> Looking at the preprocessor output, this is the problem code:

>/usr/include/boost/math/quaternion.hpp:866:

> explicit quaternion(quaternion<double> const & a_recopier)
> {
>-> *this = detail::quaternion_type_converter<float,
>double>(a_recopier);

So the
/usr/include/boost/math/quaternion.hpp:449: error: `R_component_1'
undeclared
    (first use this function)
error is related to the call to detail::quaternion_type_converter, that
makes use of R_component_1().

> }

> Notice this is a specialization. detail::quaternion_type_converter is
> defined as:

You are referring to quaternion< float > and quaternion< double >.

> namespace detail
> {
> template< typename T,
> typename U
> >
> quaternion<T> quaternion_type_converter(quaternion<U> const & rhs)
> {
> return(quaternion<T>( static_cast<T>(rhs.R_component_1()),
> static_cast<T>(rhs.R_component_2()),
> static_cast<T>(rhs.R_component_3()),
> static_cast<T>(rhs.R_component_4())));
> };
> }

> The following code appears _before_ in the file:
>
>namespace boost{ namespace math
>{
> template<typename T>
> class quaternion
> {
> [...]
> T R_component_1() const { return(a); }
> };
>}}

> The specialization for float and double appears _after_ the problem
> code.

> I have double checked that G++ 3.2 does compile the code. Regression
> in 3.3?

> Hints?

I think I understand why G++ 3.3 is getting confused. The constructors
appear near the top of the class definition, for example quaternion< float
>. The G++ compiler is strict about template checking, so will complain if
something is wrong. I think they changed the preprocessor code, so that G++
3.3 won't find the member accessors because they are generated *after* the
constructors, if you get me.

Try placing the constructor definitions at the end of the quaternion< float
> and quaternion< double > declerations.

Regards,
Reece

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger


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