I have a problem while using Rcpp on Mac (on Windows the problem does not occur).
Here is the C++ Code that causes the error.
#include <Rcpp.h>
using namespace Rcpp;
NumericVector vecpow(const IntegerVector base, const NumericVector exp)
{
NumericVector out(base.size());
std::transform(base.begin(), base.end(), exp.begin(), out.begin(), ::pow);
return out;
}
Seems like nothing too fancy or complicated.
Still I get the following error when I try to compile it:
na_ma.cpp:7:3: error: no matching function for call to 'transform' std::transform(base.begin(), base.end(), exp.begin(), out.begin(), ::pow); ^~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:2028:1: note: candidate function template not viable: requires 4 arguments, but 5 were provided transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op) ^
I am wondering how to fix this. While searching for solutions I came to some suggestions to create a Makevars file - but this did not work for me.
Would be also nice, if somebody could explain to me, why this error is occurring since I don't understand it.
g++andclang++on Linux (once I add the missing lines; would be nice if you submit a complete example next time). I suggest you check your macOS header files / added header files. - Dirk Eddelbuettelg++version 4.9.3. - Dirk Eddelbuettelclang++-4.0(the oldest one I have around) as well as the newer default. - Dirk Eddelbuettel