
Boost : 
From: Kresimir Fresl (fresl_at_[hidden])
Date: 20020407 09:33:31
Hi Joerg,
> The functions in math.h define a generic interface for scalar functions like
> real()/imag()/conj() over the types float, double and std::complex<>.
>
> The implementation currently uses non template functions for the basic types
> and template functions for std::complex<>. If the non template functions are
> not inlined, declaration and definition need to be separated AFAIK.
Yes, AFAIK you are right. But all functions in math.h are simple oneliners,
so why they are not always inlined?
> I think, it should be possible to extend numerics::type_traits<>, so that
> real() could be written for example
>
> template<class T>
> typename type_traits<T>::real_type real (const T &t) {
> return type_traits<T>::real (t);
> }
>
> and hope, that most compilers will accept this ;) If this works, it should
> be possible to eliminate instant.cpp.
It seems to work at least with g++ 2.95.4, 2.96 & 3.04. I attached
ziped diffs for `config.h', `traits.h' and `math.h' (with respect to
the latest CVS files  dated Mar, 26th) which implement your
suggestion. I introduced `NUMERICS_USE_EXTENDED_TRAITS'
macro. Simple test program is also there, and Peter's example
from the original post can be compiled, too ;o)
Can this solve Toon's problems (message `ublas linking
on gcc')?
Sincerely,
fres
PS. I added `#include <algorithm>' and `#include <iterator>' to
`traits.h' because g++ complains that `std::max()' and iterator
tags are unknown.
PPS. g++ 2.96 complains about (re)definition of `iterator<>' in
`iterator.h'. Therefore, line 26 should be
#if __GNUC__ <= 2 && __GNUC_MINOR__ <= 95
(Yes, I know that 2.96 is not official version, but ... )
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk