Skip to content
Prev 6293 / 10988 Next

[Rcpp-devel] Default value for Rcpp List

Dear Rcpp users,

 a very simple question: I have a function that has a Rcpp::List
among its arguments, and I would like to set a default values for
that List.
Unfortunately this code:

cppFunction(
  '
  List myList(List x = List::create(_["a"] = 1, _["b"] = 2))
 {
  return x;
 }
 '
)

raises the warning:

Warning message:Unable to parse C++ default value 'List::create(_["a"]
= 1, _["b"] = 2)' for argument x of function myList >
Similar code with NumericVector works fine:

cppFunction(
  '
  NumericVector myVett(NumericVector x = NumericVector::create(3))
 {
  return x;
 }
 '
 )

myVett()
# [1] 0 0 0

Am I doing something wrong? Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130814/5fc791c7/attachment.html>