Support nullable `external_ptr<>`

Đang mở
#312 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
cpp, r
Lĩnh vực
api

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
C++
Star
224
Fork
52
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của r-lib/cpp11

Tất cả issue của r-lib/cpp11

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.