Comments (4)
Yes, thanks again
from rcpp.
It's been a while but I have a faint recollection that this may be due char
and int8_t
clashing 'as they are both the same' and we weren't explicit about about preferring int8_t
(which of course does not exist in R). And I guess we need to do what we do for char
to that character variables work.
You can always write yourself a custom converter helper for this where the autoMAGIC dispatch fromt the compiler does not work. What you get from R will always be a int32_t
so for example in one package where Rcpp is used this happens (and vec
is the incoming variable from R
} else if (dtype == "INT8") {
IntegerVector v(vec);
auto n = v.length();
std::vector<int8_t> x(n);
for (auto i=0; i<n; i++) {
x[i] = static_cast<int8_t>(v[i]);
}
I don't think there is much else you can do. If it bugs you greatly that the compiler complains, see if you can improve it without side effects to char
and others. We would be interested ... but as int8_t
is somewhat rare in R application this was never a priority.
(Going via interfaces that do know int8_t
such as arrow
might be an alternative too.)
from rcpp.
Thanks for the explanation. I don't think I can improve as
, that's beyond my expertise. So, I guess, I'll resort to static_cast
as in your example.
FYI, I need this to write array tags to BAM files given the data from R, and these arrays can be of different type
from rcpp.
Yep, I know. My day job is at TileDB and the lines I quoted were from our R package which may of course encounter different int
sizes and signedness. Ditto with the single cell projects, VCF etc.
I think a one-off helper is fair workaround. Especially as template metaprogramming is hairy.
Ok to close this?
from rcpp.
Related Issues (20)
- Avoid readability-avoid-const-params-in-decls? HOT 5
- Add support for check.names HOT 5
- Compiler warning on windows-arm64 (libc++) HOT 3
- Figure 3 incorrect caption in Rcpp-introduction vignette HOT 2
- Upstreaming `std::tuple<>` support HOT 10
- sourceCpp crashes R when called about 1000 times on same code HOT 10
- Integer overflow in `MatrixRow` offset calculations for large matrices HOT 8
- Switch from S4SXP to OBJSXP HOT 2
- pass by const refererence HOT 1
- A fresh -Wformat-security issue under r-devel HOT 9
- 'CRAN package Rcpp' notice HOT 5
- Installation/Compiling Error for Package with Rcpp dependency - Ubuntu (rvmf.cpp?) HOT 5
- Exporting classes using `Rcpp::interfaces(cpp)` that are shared among multiple cpp files through header file HOT 13
- test_packageversion fails with Rcpp 1.0.12 HOT 3
- Question regarding replacement by reference of <RTYPE>Array class without making copy HOT 8
- issue building phangorn 2.11 for wasm HOT 3
- New warnings from -Wconversion -Wno-sign-conversion HOT 2
- compileAttributes and use of .External2() for calling native symbol routine HOT 6
- Exporting comments into function definitions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rcpp.