Open
Description
Would it be useful to have the initializer lists constructors also for the non writable classes, or should they really only be constructed from SEXP
, e.g. I enjoy:
cpp11::cpp_function('cpp11::writable::strings words() {
return {"person", "man", "woman", "camera", "tv"};
}')
words()
#> [1] "person" "man" "woman" "camera" "tv"
but this would be useful too:
cpp11::cpp_function('cpp11::strings words() {
return {"person", "man", "woman", "camera", "tv"};
}', quiet = FALSE)
#> clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Users/romainfrancois/.R/library/4.0/cpp11/include -I/usr/local/include -fPIC -Wall -O3 -Wall -Wimplicit-int-float-conversion -c /private/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T/RtmphIuzJv/filebd3a13b05d00/src/code_1.cpp -o /private/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T/RtmphIuzJv/filebd3a13b05d00/src/code_1.o
#> /private/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T/RtmphIuzJv/filebd3a13b05d00/src/code_1.cpp:6:10: error: no matching constructor for initialization of 'cpp11::strings' (aka 'r_vector<cpp11::r_string>')
#> return {"person", "man", "woman", "camera", "tv"};
#> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#> /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11/r_vector.hpp:61:3: note: candidate constructor not viable: requires 2 arguments, but 5 were provided
#> r_vector(SEXP data, bool is_altrep);
#> ^
#> /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11/r_vector.hpp:59:3: note: candidate constructor not viable: requires single argument 'data', but 5 arguments were provided
#> r_vector(SEXP data);
#> ^
#> /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11/r_vector.hpp:91:3: note: candidate constructor not viable: requires single argument 'rhs', but 5 arguments were provided
#> r_vector(const r_vector& rhs) {
#> ^
#> /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11/r_vector.hpp:57:3: note: candidate constructor not viable: requires 0 arguments, but 5 were provided
#> r_vector() = default;
#> ^
#> 1 error generated.
#> make: *** [/private/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T/RtmphIuzJv/filebd3a13b05d00/src/code_1.o] Error 1
#> Error in dyn.load(shared_lib, local = TRUE, now = TRUE): unable to load shared object '/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T//RtmphIuzJv/filebd3a13b05d00/src/code_1.so':
#> dlopen(/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T//RtmphIuzJv/filebd3a13b05d00/src/code_1.so, 6): image not found
words()
#> Error in .Call("_code_1_words", PACKAGE = "code_1"): "_code_1_words" not available for .Call() for package "code_1"
Created on 2020-07-24 by the reprex package (v0.3.0.9001)