File: FAQ.R

package info (click to toggle)
r-cran-cpp11 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,428 kB
  • sloc: cpp: 9,732; sh: 14; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 1,414 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(cpp11)

## -----------------------------------------------------------------------------
add_some <- function(x, amount = 1) {
  add_some_(x, amount)
}
add_some(1)
add_some(1, amount = 5)

## -----------------------------------------------------------------------------
is_named("foo")

is_named(c(x = "foo"))

## -----------------------------------------------------------------------------
my_false()

my_true()

my_both()

## -----------------------------------------------------------------------------
x <- new.env()

foo_exists(x)

set_foo(x, 1)

foo_exists(x)

## -----------------------------------------------------------------------------
push_raws()

## -----------------------------------------------------------------------------
x <- c(1L, 2L, 3L, 4L)
.Internal(inspect(x))
add_one(x)
.Internal(inspect(x))
x

## ----error=TRUE---------------------------------------------------------------
try({
test_destructor_ok()
})

## ----eval=FALSE---------------------------------------------------------------
# test_destructor_bad()
# #> Error: oh no!

## -----------------------------------------------------------------------------
set.seed(123)
x <- sample(letters, 1e6, replace = TRUE)

bench::mark(
  test_extract_cpp11(x),
  test_extract_r_api(x)
)