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.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ LinkingTo: cpp11
19
19
```
20
20
21
21
Then decorate C++ functions you want to expose to R with `[[cpp11::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.*
22
+
*Note that this is a [C++11 attribute](https://en.cppreference.com/w/cpp/language/attributes.html), not a comment like is used in Rcpp.*
23
23
24
24
cpp11 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.
Copy file name to clipboardExpand all lines: vignettes/cpp11.Rmd
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ Typical bottlenecks that C++ can address include:
45
45
The aim of this vignette is to discuss only those aspects of C++ and cpp11 that are absolutely necessary to help you eliminate bottlenecks in your code.
46
46
We won't spend much time on advanced features like object-oriented programming or templates because the focus is on writing small, self-contained functions, not big programs.
47
47
A working knowledge of C++ is helpful, but not essential.
48
-
Many good tutorials and references are freely available, including <https://www.learncpp.com/> and <https://en.cppreference.com/w/cpp>.
48
+
Many good tutorials and references are freely available, including <https://www.learncpp.com/> and <https://en.cppreference.com/w/cpp.html>.
49
49
For more advanced topics, the *Effective C++* series by Scott Meyers is a popular choice.
All R objects have attributes, which can be queried and modified with `.attr()`.
511
511
cpp11 also provides `.names()` as an alias for the `names` attribute.
512
512
The following code snippet illustrates these methods.
513
-
Note the use of `{}`[initializer list](https://en.cppreference.com/w/cpp/utility/initializer_list) syntax.
513
+
Note the use of `{}`[initializer list](https://en.cppreference.com/w/cpp.html/utility/initializer_list) syntax.
514
514
This allows you to create an R vector from C++ scalar values:
515
515
516
516
```{r attribs, engine = "cpp11"}
@@ -650,7 +650,7 @@ The standard template library (STL) provides a set of extremely useful data stru
650
650
This section will explain some of the most important algorithms and data structures and point you in the right direction to learn more.
651
651
I can't teach you everything you need to know about the STL, but hopefully the examples will show you the power of the STL, and persuade you that it's useful to learn more.
652
652
653
-
If you need an algorithm or data structure that isn't implemented in STL, one place to look is [boost](https://www.boost.org/doc/).
653
+
If you need an algorithm or data structure that isn't implemented in STL, one place to look is [boost](https://www.boost.org/libraries/).
654
654
Installing boost on your computer is beyond the scope of this vignette, but once you have it installed, you can use boost data structures and algorithms by including the appropriate header file with (e.g.) `#include <boost/array.hpp>`.
655
655
656
656
### Using iterators
@@ -736,7 +736,7 @@ local({
736
736
### Algorithms
737
737
738
738
The `<algorithm>` header provides a large number of algorithms that work with iterators.
739
-
A good reference is available at <https://en.cppreference.com/w/cpp/algorithm>.
739
+
A good reference is available at <https://en.cppreference.com/w/cpp.html/algorithm>.
740
740
For example, we could write a basic cpp11 version of `findInterval()` that takes two arguments, a vector of values and a vector of breaks, and locates the bin that each x falls into.
741
741
This shows off a few more advanced iterator features.
742
742
Read the code below and see if you can figure out how it works.
@@ -790,7 +790,7 @@ The most important of these data structures are the `vector`, the `unordered_set
790
790
We'll focus on these three in this section, but using the others is similar: they just have different performance trade-offs.
791
791
For example, the `deque` (pronounced "deck") has a very similar interface to vectors but a different underlying implementation that has different performance trade-offs.
792
792
You may want to try it for your problem.
793
-
A good reference for STL data structures is <https://en.cppreference.com/w/cpp/container> --- I recommend you keep it open while working with the STL.
793
+
A good reference for STL data structures is <https://en.cppreference.com/w/cpp.html/container> --- I recommend you keep it open while working with the STL.
794
794
795
795
cpp11 knows how to convert from many STL data structures to their R equivalents, so you can return them from your functions without explicitly converting to R data structures.
796
796
@@ -843,7 +843,7 @@ list rle_cpp(doubles x) {
843
843
(An alternative implementation would be to replace `i` with the iterator `lengths.rbegin()` which always points to the last element of the vector.
844
844
You might want to try implementing that.)
845
845
846
-
Other methods of a vector are described at <https://en.cppreference.com/w/cpp/container/vector>.
846
+
Other methods of a vector are described at <https://en.cppreference.com/w/cpp.html/container/vector>.
847
847
848
848
### Sets
849
849
@@ -854,7 +854,7 @@ Unordered sets can somtimes be much faster (because they use a hash table intern
854
854
Often even if you need an ordered set, you could consider using an unordered set and then sorting the output.
855
855
Benchmarking with your expected dataset is the best way to determine which is fastest for your data.
856
856
Like vectors, sets are templated, so you need to request the appropriate type of set for your purpose: `unordered_set<int>`, `unordered_set<bool>`, etc.
857
-
More details are available at <https://en.cppreference.com/w/cpp/container/set> and <https://en.cppreference.com/w/cpp/container/unordered_set>.
857
+
More details are available at <https://en.cppreference.com/w/cpp.html/container/set> and <https://en.cppreference.com/w/cpp.html/container/unordered_set>.
858
858
859
859
The following function uses an unordered set to implement an equivalent to `duplicated()` for integer vectors.
Copy file name to clipboardExpand all lines: vignettes/internals.Rmd
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -108,7 +108,7 @@ The various methods for both functions are defined in [cpp11/as.hpp](https://git
108
108
109
109
This is definitely the most complex part of the cpp11 code, with extensive use of [template metaprogramming](https://en.wikipedia.org/wiki/Template_metaprogramming).
110
110
In particular the [substitution failure is not an error (SFINAE)](https://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error) technique is used to control overloading of the functions.
111
-
If we could use C++20 a lot of this code would be made simpler with [Concepts](https://en.cppreference.com/w/cpp/language/constraints), but alas.
111
+
If we could use C++20 a lot of this code would be made simpler with [Concepts](https://en.cppreference.com/w/cpp/language/constraints.html), but alas.
112
112
113
113
The most common C++ types are included in the test suite and should work without issues, as more exotic types are used in real projects additional issues may arise.
0 commit comments