Hubert Holin wrote:
I welcome any suggestion on that matter (and would most welcome somebody showing me what I got wrong :-) ).

Maybe a two-step overload is what you are looking for:


<code>

#include <complex>
#include <iostream>
#include <valarray>


// (1/1) Plain vanilla templated function


template<typename T>
T              f2(T x)
{
   ::std::cout << "Plain vanilla templated function" << ::std::endl;

   return(x);
}


// (1/2) Template-template function


template<typename T, template<typename> class U>
U<T>           f2(U<T> x)
{
   ::std::cout << "Template-template function" << ::std::endl;

   return(x);
}

// (2/1) Plain vanilla templated function

template<typename T>
T              f(T x)
{
   return f2(x);
}

// (2/2) Valarray function

template<typename T>
::std::valarray<T>   f(const ::std::valarray<T> & x)
{
   ::std::cout << "Valarray function" << ::std::endl;

::std::valarray<T> result = x;

   return(result);
}



int main()
{
   double                     x(1);

f(x);

::std::complex<double> y(0,1);

f(y);

const ::std::valarray<double> z(3);

   f(z);
}

</code>

This works for me and outputs:

Plain vanilla templated function
Template-template function
Valarray function

Hope it helps...

Regards, Daniel

--
Daniel Frey

aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: [EMAIL PROTECTED], web: http://www.aixigo.de


_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to