Skip to content

Commit 5a12b7a

Browse files
bernhardmgrubersponce
authored andcommitted
Small fixes to ranges
1 parent ed852f5 commit 5a12b7a

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

talk/morelanguage/ranges.tex

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
\frametitlecpp[20]{Ranges}
55
\begin{block}{The range concept}
66
\begin{itemize}
7-
\item A range is a group of items that you can iterate over
7+
\item A range is a sequence of items that you can iterate over
88
\item It must provide iterators to its beginning and end, obtainable via \mintinline{cpp}{std::range::begin} and \mintinline{cpp}{std::range::end}
99
\item Range concepts are located in \mintinline{cpp}{std::ranges} namespace
1010
\item All STL containers are ranges
1111
\end{itemize}
1212
\end{block}
1313
\begin{exampleblock}{Variations on ranges}
14-
There are actually different type of ranges
14+
There are actually different types of ranges
1515
\begin{itemize}
1616
\item \mintinline{cpp}{input_range}, \mintinline{cpp}{output_range}, \mintinline{cpp}{forward_range}, \mintinline{cpp}{bidirectional_range}, \mintinline{cpp}{random_access_range}, \mintinline{cpp}{contiguous_range}
1717
\item corresponding to the different iterator categories
@@ -25,13 +25,13 @@
2525
\begin{itemize}
2626
\item A \mintinline{cpp}{view} is a non-owning object built from a range or another view after applying some range adaptor(s)
2727
\item The time complexity to copy, move, assign is constant
28-
\item Range adaptors can be applied/changed with \mintinline{cpp}{|} and are lazy
28+
\item Range adaptors can be applied/chained with \mintinline{cpp}{|} and are lazy
2929
\item They live in the \mintinline{cpp}{std::views} namespace
3030
\item They introduce easy functional programming to the STL
3131
\end{itemize}
3232
\end{block}
3333
\begin{exampleblock}{Example}
34-
{ \scriptsize
34+
{ \small
3535
\begin{cppcode*}{gobble=4}
3636
auto const numbers = std::views::iota(0, 6);
3737
auto even = [](int i) { return 0 == i % 2; };
@@ -64,21 +64,22 @@
6464

6565
\begin{frame}[fragile]
6666
\frametitlecpp[23]{Back to laziness}
67-
\begin{exampleblock}{\texttt{view}s are lazy}
67+
\begin{block}{Views are lazy}
6868
\begin{itemize}
6969
\item Computation is only triggered when iterating
7070
\item And can be stopped by e.g. \mintinline{cpp}{take}
7171
\item Here, the minimal number of iterations is performed
7272
\end{itemize}
73-
{ \scriptsize
74-
\begin{cppcode*}{gobble=2}
75-
// print first 20 prime numbers above 1000000
76-
for (int i: std::views::iota(1000000) | std::views::filter(odd)
77-
| std::views::filter(isPrime)
78-
| std::views::take(20)) {
79-
std::cout << i << " ";
80-
}
81-
\end{cppcode*}
82-
}
73+
\end{block}
74+
\begin{exampleblock}{Example}
75+
\begin{cppcode*}{gobble=2}
76+
// print first 20 prime numbers above 1000000
77+
for (int i: std::views::iota(1000000)
78+
| std::views::filter(odd)
79+
| std::views::filter(isPrime)
80+
| std::views::take(20)) {
81+
std::cout << i << " ";
82+
}
83+
\end{cppcode*}
8384
\end{exampleblock}
8485
\end{frame}

0 commit comments

Comments
 (0)