Boost logo

Boost :

From: Michael Stevens (support-1_at_[hidden])
Date: 2002-08-22 22:54:02


Hi All,

I am try to resolve some portability issues with Hubert's
Quaternion/Octonian library. The aim is to get compatibility with
GCC3.1/2 and VC7. The final problem is what I believe to be
non-complient handling of explict specializations by both compilers. The
Quaternion/Octonian library provides explicit specialsations of the
quaternion/octonian class templates for the float, double and long
double types. These specialisation provide additional type conversions
so a portable solution would be handy.

It is easiest to show the compiler problem with the following code snippet

// explict.hpp Class with explict specialization
template <class T>
struct TC {
};

template <>
struct TC<int> {
    void f2(); // Decleration of class template
specialisation member function
};

void TC<int>::f2() // Definintion of class template specialisation
member function
{}

The problem is that both compilers treat the template function
definition as if it was an ordinary function definition. This is a big
problem if the explict.hpp header is included in more then one
compilation unit. The function is multiply defined and results in link
errors.

The same problem does not occur if the definition is moved inline into
the class template specialation definition. However this arangment would
require restructing much of the quaternion/octonian headers.

Looking at the C++ standard I cannot see that the way the these
compilers treat these definitions as ordinary function definitions is
correct behaviour. Does anyone else have any more experience of this?
Any suggestions/workarounds?

Thanks,
    Michael Stevens Australian Center for Field Robotics


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