I am trying to write a C++/Rcpp function that has an optional argument whos default needs to be a vector of length 1 with a value of 0. The following does not compile properly:
cppFunction("std::vector<int> test(std::vector<int> out = {0}) {
return out;
}")
I get the following error:
Error in cppFunction("std::vector test(std::vector out = {1}) {\n return out;\n}") : No function definition found In addition: Warning messages: 1: No function found for Rcpp::export attribute at fileee5f629605d7.cpp:5 2: In sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, : No Rcpp::export attributes or RCPP_MODULE declarations found in source
What is the right way to do this?