External pointers and attributes
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 50/100
Research direction
Start with cpp11/external_pointer.hpp and the R reproduction in the issue; compare the vendored cpp11 implementation with the referenced DuckDB commit. Confirm that moving an external pointer preserves its attributes, then rerun the supplied example and verify the third and fourth outputs retain the class attribute.
Written by the indexing model from the issue text.
Description
Invoking the move constructor of external_pointer<> clears attributes on an external pointer object.
I would expect the third and fourth output to be identical to the second output. A possible fix is https://github.com/duckdb/duckdb/pull/6526/commits/12f6f10c12edda4d1153777d7a172279be11191c (this project uses a vendored version of cpp11).
library(cpp11)
cpp_source(
code = '
#include "cpp11/external_pointer.hpp"
#include "cpp11/strings.hpp"
template <class X>
cpp11::external_pointer<int> test_int() {
X a = 0;
auto p = cpp11::external_pointer<X>(&a, false);
Rf_PrintValue(p);
Rf_setAttrib(p, R_ClassSymbol, cpp11::writable::strings({"foo"}));
Rf_PrintValue(p);
return std::move(p);
}
[[cpp11::register]]
SEXP test() {
auto p = cpp11::sexp(test_int<int>());
Rf_PrintValue(p);
return p;
}
'
)
out <- test()
#> <pointer: 0x16f0af42c>
#> <pointer: 0x16f0af42c>
#> attr(,"class")
#> [1] "foo"
#> <pointer: 0x16f0af42c>
out
#> <pointer: 0x16f0af42c>
Created on 2023-03-02 with reprex v2.0.2
- Dominant language
- C++
- Stars
- 224
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from r-lib/cpp11
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·