r-lib / cpp11

cpp11 helps you to interact with R objects using C++ code.
https://cpp11.r-lib.org/
Other
201 stars 48 forks source link

Include a `nameof<>()` utility #112

Open bkietz opened 4 years ago

bkietz commented 4 years ago

It's possible to implement a nameof<T>() which provides a string representation of T without requiring RTTI or demangling at runtime.

assert(nameof<r_string>() == "cpp11::r_string");

This might be helpful in a number of cases including providing better error messages from generics.

For in-the-wild use, see: https://github.com/apache/arrow/pull/8246/commits/87c26f7a7e5a393681057923a790f6448ea07817#diff-db94c392857c3bad4f5f69e86cde917bR164-R165

romainfrancois commented 4 years ago

As a frequent user of the DEMANGLE macro from Rcpp, I would definitely welcome this.

bkietz commented 3 years ago

https://gist.github.com/bkietz/7899f477e86df49f21ab17201c518d74

romainfrancois commented 2 years ago

Do you want to work on a pull request @bkietz ?

bkietz commented 2 years ago

Sure, I'll write one today