Problem with templated special functions

J

Juanjo

Hi,

I have a piece of code that looks like below. The code simply does not
compile because the compiler chooses to believe that std::cos<double>
has type signature std::complex<double> cos(std::complex<double>)

The reason I think is that there are two contradictory definitions,
one in cmath, ::using cos, and another one in complex which reads
template<typename _Tp> complex<_Tp> cos(const complex<_Tp>&);

This is with g++ 4.3. Does anybody have a solution? Am I trying the
impossible?

Juanjo

#include <cmath>
#include <complex>
#include <tensor/tensor.h>

namespace tensor {

Tensor<double> cos(const Tensor<double> &t) {
Tensor<double> output(t.dimensions());
// The iterators here have type double * and const double *
std::transform(t.begin(), t.end(), output.begin(),
std::cos<double>);
return output;
}

} // namespace tensor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top