You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cpp4r helps you to interact with R objects using C++ code.
11
-
Its goals and syntax are similar to the excellent [Rcpp](https://cran.r-project.org/package=Rcpp) package.
12
+
It is a fork of the [cpp11](https://cran.r-project.org/package=cpp) package with identical syntax and similar goals.
13
+
14
+
cpp4r can be used as a replacement for cpp11 in existing or new packages. Think of cpp11 and cpp4r as MySQL and MariaDB: they are almost identical, but cpp4r has some extra features.
15
+
16
+
After discussing some [pull requests](https://github.com/r-lib/cpp11/pulls/pachadotdev) with Hadley Wickham from Posit, it was mentioned that I should create my own fork to add the following features:
17
+
18
+
-[x] Convert ordered and unordered C++ maps to R lists.
19
+
-[x] Roxygen support on C++ side.
20
+
-[x] Allow `dimnames` atribute with matrices on C++ side.
21
+
-[x] Support nullable `external_ptr<>`.
22
+
-[x] Use values added to a vector with `push_back()` immediately.
23
+
-[x] Support bidirectional passing of complex numbers/vectors.
24
+
-[x] Provide flexibility with data types (e.g., cpp4r's `as_integers()` and `as_doubles()` accept logical inputs while cpp11's do not).
25
+
-[x] Some internal optimizations for better speed (e.g., https://github.com/r-lib/cpp11/pull/463 and https://github.com/r-lib/cpp11/pull/430).
12
26
13
27
## Using cpp4r in a package
14
28
@@ -19,7 +33,6 @@ LinkingTo: cpp4r
19
33
```
20
34
21
35
Then decorate C++ functions you want to expose to R with `[[cpp4r::register]]`.
22
-
*Note that this is a [C++11 attribute](https://en.cppreference.com/w/cpp/language/attributes), not a comment like is used in Rcpp.*
23
36
24
37
cpp4r is a header only library with no hard dependencies and does not use a shared library, so it is straightforward and reliable to use in packages without fear of compile-time and run-time mismatches.
25
38
@@ -28,63 +41,16 @@ This ensures the headers will remain unchanged until you explicitly update them.
28
41
29
42
## Getting started
30
43
31
-
See [vignette("cpp4r")](https://cpp4r.r-lib.org/articles/cpp4r.html) to get started using cpp4r in your scripts, particularly if you are new to C++ programming.
44
+
See [vignette("cpp4r")](https://cpp4r.org/articles/cpp4r.html) to get started using cpp4r in your scripts, particularly if you are new to C++ programming.
32
45
33
46
## Getting help
34
47
35
-
[Posit Community](https://forum.posit.co/) is the best place to ask for help using cpp4r or interfacing C++ with R.
36
-
37
-
## Motivations
38
-
39
-
[Rcpp](https://cran.r-project.org/package=Rcpp) has been a widely successful project, however over the years a number of issues and additional C++ features have arisen.
40
-
Adding these features to Rcpp would require a great deal of work, or in some cases would be impossible without severely breaking backwards compatibility.
41
-
42
-
**cpp4r** is a ground up rewrite of C++ bindings to R with different design trade-offs and features.
- Having a more straightforward, [simpler implementation](https://cpp4r.r-lib.org/articles/motivations.html#simpler-implementation).
52
-
- Faster [compilation time](https://cpp4r.r-lib.org/articles/motivations.html#compilation-speed) with lower memory requirements.
53
-
- Being *completely*[header only](https://cpp4r.r-lib.org/articles/motivations.html#header-only) to avoid ABI issues.
54
-
- Capable of [vendoring](https://cpp4r.r-lib.org/articles/motivations.html#vendoring) if desired.
55
-
- More robust [protection](https://cpp4r.r-lib.org/articles/motivations.html#protection) using a much more efficient linked list data structure.
56
-
-[Growing vectors](https://cpp4r.r-lib.org/articles/motivations.html#growing-vectors) more efficiently.
57
-
58
-
See [vignette("motivations")](https://cpp4r.r-lib.org/articles/motivations.html) for full details on the motivations for writing cpp4r.
59
-
60
-
## Conversion from Rcpp
48
+
Please open an issue or email me. I will do my best to respond before 48 hours.
61
49
62
-
See [vignette("converting")](https://cpp4r.r-lib.org/articles/converting.html) if you are already familiar with Rcpp or have an existing package that uses Rcpp and want to convert it to use cpp4r.
50
+
## Contributing
63
51
64
-
## Learning More
65
-
66
-
-[Welding R and C++](https://www.youtube.com/watch?v=_kq0N0FNIjA) - Presentation at SatRday Columbus [(slides)](https://speakerdeck.com/jimhester/cpp4r-welding-r-and-c-plus-plus)
67
-
68
-
69
-
## Internals
70
-
71
-
See [vignette("internals")](https://cpp4r.r-lib.org/articles/internals.html) for details on the cpp4r implementation or if you would like to contribute to cpp4r.
52
+
Contributions are welcome! Please see the [internals vignette](https://cpp4r.r-lib.org/articles/internals.html) for details about design choices and coding style.
72
53
73
54
## Code of Conduct
74
55
75
56
Please note that the cpp4r project is released with a [Contributor Code of Conduct](https://cpp4r.r-lib.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
76
-
77
-
## Thanks
78
-
79
-
cpp4r would not exist without Rcpp.
80
-
Thanks to the Rcpp authors, Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou, Nathan Russell, Douglas Bates and John Chambers for their work writing and maintaining Rcpp.
81
-
82
-
## Clang format
83
-
84
-
To match GHA, use clang-format-12 to format C++ code. With systems that provide clang-format-14 or newer, you can use Docker:
0 commit comments