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
Copy file name to clipboardExpand all lines: README.Rmd
+29-13Lines changed: 29 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -26,28 +26,37 @@ knitr::opts_chunk$set(
26
26
cpp4r helps you to interact with R objects using C++ code.
27
27
It is a fork of the [cpp11](https://cran.r-project.org/package=cpp11) package with identical syntax and similar goals.
28
28
29
-
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.
29
+
⚠️Important⚠️: cpp4r was created to ease writing functions in your own packages and does not offer on-the-fly
30
+
compilation for code snippets.
30
31
31
-
After discussing some [pull requests](https://github.com/pachadotdev/cpp11/pulls/pachadotdev) with Hadley Wickham from Posit, it was mentioned that I should create my own fork to add the following features:
32
+
cpp4r can be used as a replacement for cpp11 in existing or new packages. Think of cpp11 and cpp4r as MySQL and MariaDB:
33
+
they are almost identical, but cpp4r has some extra features.
34
+
35
+
After discussing some [pull requests](https://github.com/pachadotdev/cpp11/pulls/pachadotdev) with Hadley Wickham from
36
+
Posit, it was mentioned that I should create my own fork to add the following features:
32
37
33
38
-[x] Convert ordered and unordered C++ maps to R lists.
34
39
-[x] Roxygen support on C++ side.
35
40
-[x] Allow `dimnames` attribute with matrices on C++ side.
36
41
-[x] Support nullable `external_ptr<>`.
37
42
-[x] Use values added to a vector with `push_back()` immediately.
38
43
-[x] Support bidirectional passing of complex numbers/vectors.
39
-
-[x] Provide flexibility with data types (e.g., cpp4r's `as_integers()` and `as_doubles()` accept logical inputs while cpp11's do not).
40
-
-[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).
44
+
-[x] Provide flexibility with data types (e.g., cpp4r's `as_integers()` and `as_doubles()` accept logical inputs while
45
+
cpp11's do not).
46
+
-[x] Some internal optimizations for better speed (e.g., https://github.com/r-lib/cpp11/pull/463 and
47
+
https://github.com/r-lib/cpp11/pull/430).
41
48
42
49
## Getting started
43
50
44
-
Check the [documentation](https://cpp4r.org/) to get started using cpp4r in your scripts, particularly if you are new to C++ programming.
51
+
Check the [documentation](https://cpp4r.org/) to get started using cpp4r in your scripts, particularly if you are new to
52
+
C++ programming.
45
53
46
54
## Using cpp4r in a package
47
55
48
56
Create a new package with `cpp4r::pkg_template("~/path/to/mypkg")` and then edit the generated files.
49
57
50
-
To add cpp4r to an existing package, put your C++ files in the `src/` directory and add the following to your DESCRIPTION file:
58
+
To add cpp4r to an existing package, put your C++ files in the `src/` directory and add the following to your
59
+
DESCRIPTION file:
51
60
52
61
```
53
62
LinkingTo: cpp4r
@@ -63,25 +72,32 @@ Then add a roxygen header, for example, to `R/mypkg-package.R`:
63
72
64
73
Then decorate C++ functions you want to expose to R with `[[cpp4r::register]]`.
65
74
66
-
cpp4r is a header only library with no hard dependencies and does not use a shared library. It is straightforward and reliable to use in packages without fear of compile-time and run-time mismatches.
75
+
cpp4r is a header only library with no hard dependencies and does not use a shared library. It is straightforward and
76
+
reliable to use in packages without fear of compile-time and run-time mismatches.
67
77
68
78
## Vendoring
69
79
70
-
You can [vendor](https://cpp4r.org/articles/01-motivations.html) the current installed version of cpp4r headers into your package with `cpp4r::vendor()`.
80
+
You can [vendor](https://cpp4r.org/articles/01-motivations.html) the current installed version of cpp4r headers into
81
+
your package with `cpp4r::vendor()`.
71
82
72
-
The [cpp4rvendor](https://github.com/pachadotdev/cpp4r/tree/main/cpp4rtest) package shows an example of vendoring cpp4r headers.
83
+
The [cpp4rvendor](https://github.com/pachadotdev/cpp4r/tree/main/cpp4rtest) package shows an example of vendoring cpp4r
84
+
headers.
73
85
74
-
Vendoring ensures the headers will remain unchanged until you explicitly update them. The advantage is that your package will not break if there are breaking changes in future versions of cpp4r. The disadvantage is
75
-
that you will not get bug fixes and new features unless you update the vendored headers.
86
+
Vendoring ensures the headers will remain unchanged until you explicitly update them. The advantage is that your package
87
+
will not break if there are breaking changes in future versions of cpp4r. The disadvantage is that you will not get bug
88
+
fixes and new features unless you update the vendored headers.
76
89
77
90
## Getting help
78
91
79
92
Please open an issue or email me. I will do my best to respond before 48 hours.
80
93
81
94
## Contributing
82
95
83
-
Contributions are welcome! Please see the [internals vignette](https://cpp4r.org/articles/15-internals.html) for details about design choices and coding style.
96
+
Contributions are welcome! Please see the [internals vignette](https://cpp4r.org/articles/15-internals.html) for details
97
+
about design choices and coding style.
84
98
85
99
## Code of Conduct
86
100
87
-
Please note that the cpp4r project is released with a [Contributor Code of Conduct](https://cpp4r.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
101
+
Please note that the cpp4r project is released with a
102
+
[Contributor Code of Conduct](https://cpp4r.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to
0 commit comments