Support nullable `external_ptr<>`
还没有人认领这个 Issue。
评估
调研方向
Read cpp11/external_pointer.hpp and start with the external_pointer cases exercised by the cpp_source examples. Reproduce both nullptr and R_NilValue inputs in R; done means the chosen nullable behavior is consistent in both directions and existing external-pointer behavior remains valid.
由索引模型根据 Issue 内容生成。
描述
Currently, a nullptr but not an R_NilValue can be assigned to an external_ptr<> object. This is inconsistent and surprising, in particular because the roundtrip works correctly the other way. Should we support this?
CC @hannes @TMonster.
library(cpp11)
# Works
cpp_source(
code = '
#include "cpp11/external_pointer.hpp"
#include "cpp11/strings.hpp"
[[cpp11::register]]
cpp11::external_pointer<int> test() {
return cpp11::external_pointer<int>(nullptr);
}
'
)
test()
#> NULL
# Fails, but perhaps shouldn't
cpp_source(
code = '
#include "cpp11/external_pointer.hpp"
#include "cpp11/strings.hpp"
[[cpp11::register]]
cpp11::external_pointer<int> test() {
return cpp11::external_pointer<int>(R_NilValue);
}
'
)
test()
#> Error: Invalid input type, expected 'externalptr' actual 'NULL'
Created on 2023-04-02 with reprex v2.0.2
- 主要语言
- C++
- 星标
- 224
- 派生
- 52
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
r-lib/cpp11 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 48/100
-
难度 5/5 一周以上 新手友好度 20/100
-
难度 3/5 1-2 天 新手友好度 42/100
-
难度 3/5 1-2 天 新手友好度 45/100
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
AXERA-TECH/ax-llm#77 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
games-on-whales/wolf#509 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
-
bug-unconfirmed
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 74/100
NVIDIA/cuda-samples#453 ·