Rcpp映射返回
Rcpp map return
我正试图返回一个从c++到r的映射。我在c++中的代码如下(如https://github.com/RcppCore/Rcpp/blob/master/inst/tinytest/cpp/wrap.cpp):
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
IntegerVector map_string_int(){
std::map< std::string, int > m ;
m["b"] = 100;
m["a"] = 200;
m["c"] = 300;
return wrap(m);
}
我的r代码如下:
require(Rcpp)
Rcpp::sourceCpp(test.cpp')
map_string_int()
尽管代码编译时没有任何错误,但当我调用该函数时,我的r会话会立即终止。有什么想法吗?
[编辑]
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=Portuguese_Portugal.1252
[2] LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252
[4] LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.1252
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] Rcpp_0.11.3
loaded via a namespace (and not attached):
[1] tools_3.1.1
决定尝试另一个编译器,结果成功了!
我已安装Rtools编译器(http://cran.r-project.org/bin/windows/Rtools/)之后,仅更改系统路径以指向Rtools安装文件夹中的bin文件夹。
相关文章:
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- 如何在映射中返回null
- 从函数返回对映射的引用
- 为什么我不能返回带有透明函子的法线映射引用?
- CGAL-三角网格,返回面对面映射
- 返回各种类型的函数的SWIG类型映射
- 类型映射资源并将列表转换为矢量(并返回)
- 访问range_expression中的嵌套元素会返回不完整的映射(段错误)
- C++ 返回映射中对象的值
- 返回字符串和不同向量数据类型的映射C++
- 取消引用映射迭代器时返回对临时的引用
- 当请求的键丢失时,有没有办法从向量映射返回 std::vector ref?
- 为什么 unordered_map::equal_range upper_bound 如果键小于第一个映射元素,则返回
- 整数和元组的静态 STL 映射返回 0
- C++函数来返回基于参数的比较器通用映射类型?
- 为什么要对 map::find 应用不存在的键将返回一个C++中第一个值映射大小的迭代器
- typedef映射作为返回类型到函数会引发编译器错误
- 返回映射的模板化类成员函数的声明
- 交叉引用类并返回映射<字符串,类>
- 如何创建一个适配器,该适配器将使用键的谓词根据筛选的键返回映射值