Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rcpp error: ‘unique_ptr’ is not a member of ‘std’

Tags:

c++

r

c++11

rcpp

I am using RStudio on Ubuntu 16.04 LTS and have created code for an R package using Rcpp.

My code worked fine until I moved it in to the R package. Now I am getting the error:

error: ‘unique_ptr’ is not a member of ‘std’

The guilty line of code is:

typedef std::list<std::unique_ptr<Random> > ears_t;

The top of my cpp file contains reference to the cpp11 plugin

// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::depends(BH)]]
#include <Rcpp.h>
#include <vector>
#include <memory>
#include <boost/ptr_container/ptr_vector.hpp>
using namespace Rcpp;

The description file links to and imports the various packages:

LinkingTo: Rcpp, BH
Imports: Rcpp, BH, raster, XML

I have seen one post that suggests the problem relates to the non-inclusion of the memory class and another that relates to C++11.

Either way I am unsure how to solve the issue. Any suggestions would be greatly appreciated.

like image 731
haffamoto Avatar asked Oct 31 '25 12:10

haffamoto


1 Answers

For packages with C++11 you want to have the following in your DESCRIPTION file:

SystemRequirements: C++11

As suggested by Dirk another possibility is adding the following to a src/Makevars{.win} file:

CXX_STD=C++11
like image 55
cdeterman Avatar answered Nov 03 '25 05:11

cdeterman