Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions talk/basicconcepts/classenum.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
\center ``members'' grouped together under one name
\end{mdframed}
\begin{multicols}{2}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
struct Individual {
unsigned char age;
float weight;
Expand All @@ -21,7 +21,7 @@
};
\end{cppcode*}
\columnbreak
\begin{cppcode*}{gobble=2,firstnumber=14}
\begin{cppcode*}{firstnumber=14}
Individual *ptr = &student;
ptr->age = 25;
// same as: (*ptr).age = 25;
Expand Down Expand Up @@ -56,7 +56,7 @@
\center ``members'' packed together at same memory location
\end{mdframed}
\begin{multicols}{2}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
union Duration {
int seconds;
short hours;
Expand Down Expand Up @@ -104,7 +104,7 @@
\end{itemize}
\end{block}
\begin{multicols}{2}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
enum VehicleType {

BIKE, // 0
Expand All @@ -114,7 +114,7 @@
VehicleType t = CAR;
\end{cppcode*}
\columnbreak
\begin{cppcode*}{gobble=2,firstnumber=8}
\begin{cppcode*}{firstnumber=8}
enum VehicleType
: int { // C++11
BIKE = 3,
Expand Down Expand Up @@ -158,7 +158,7 @@
\begin{frame}[fragile]
\frametitlecpp[98]{More sensible example}
\begin{multicols}{2}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
enum class ShapeType {
Circle,
Rectangle
Expand All @@ -171,7 +171,7 @@
\end{cppcode*}
\columnbreak
\pause
\begin{cppcode*}{gobble=2,firstnumber=10}
\begin{cppcode*}{firstnumber=10}
struct Shape {
ShapeType type;
union {
Expand All @@ -183,15 +183,15 @@
\end{multicols}
\pause
\begin{multicols}{2}
\begin{cppcode*}{gobble=2,firstnumber=17}
\begin{cppcode*}{firstnumber=17}
Shape s;
s.type =
ShapeType::Circle;
s.radius = 3.4;

\end{cppcode*}
\columnbreak
\begin{cppcode*}{gobble=2,firstnumber=20}
\begin{cppcode*}{firstnumber=20}
Shape t;
t.type =
Shapetype::Rectangle;
Expand All @@ -205,14 +205,14 @@
\frametitle{typedef and using \hfill \cpp98 / \cpp11}
Used to create type aliases
\begin{alertblock}{\cpp98}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
typedef std::uint64_t myint;
myint count = 17;
typedef float position[3];
\end{cppcode*}
\end{alertblock}
\begin{exampleblock}{\cpp11}
\begin{cppcode*}{gobble=2,firstnumber=4}
\begin{cppcode*}{firstnumber=4}
using myint = std::uint64_t;
myint count = 17;
using position = float[3];
Expand Down
2 changes: 1 addition & 1 deletion talk/basicconcepts/control.tex
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
\begin{frame}[fragile]
\frametitlecpp[98]{Control structures: switch}
\begin{block}{Syntax}
\begin{cppcode*}{gobble=0}
\begin{cppcode*}{}
switch(identifier) {
case c1 : statements1; break;
case c2 : statements2; break;
Expand Down
2 changes: 1 addition & 1 deletion talk/basicconcepts/coresyntax.tex
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
\item Custom conversion and promotion rules
\end{itemize}
\end{block}
\begin{cppcode*}{gobble=4}
\begin{cppcode*}{}
#include <stdfloat> // may define these:

std::float16_t = 3.14f16; // 16 (1+5+10) bit float
Expand Down
16 changes: 8 additions & 8 deletions talk/basicconcepts/functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
\begin{frame}[fragile]
\frametitlecpp[98]{Functions}
\begin{multicols}{2}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
// with return type
int square(int a) {
return a * a;
Expand All @@ -16,7 +16,7 @@
}
\end{cppcode*}
\columnbreak
\begin{cppcode*}{gobble=2,firstnumber=11}
\begin{cppcode*}{firstnumber=11}
// no return
void log(char* msg) {
std::cout << msg;
Expand All @@ -43,7 +43,7 @@
\begin{frame}[fragile]
\frametitlecpp[98]{Function default arguments}
\begin{multicols}{2}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
// must be the trailing
// argument
int add(int a,
Expand All @@ -55,7 +55,7 @@

\end{cppcode*}
\columnbreak
\begin{cppcode*}{gobble=2,firstnumber=11}
\begin{cppcode*}{firstnumber=11}
// multiple default
// arguments are possible
int add(int a = 2,
Expand Down Expand Up @@ -361,7 +361,7 @@
\end{itemize}
\end{block}
\begin{exampleblock}{}
\begin{cppcode*}{gobble=6}
\begin{cppcode*}{}
int sum(int b); // 1
int sum(int b, int c); // 2, ok, overload
// float sum(int b, int c); // disallowed
Expand Down Expand Up @@ -399,7 +399,7 @@
\end{itemize}
\end{goodpractice}
\begin{exampleblock}{Example: Good}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
/// Count number of dilepton events in data.
/// \param d Dataset to search.
unsigned int countDileptons(Data &d) {
Expand All @@ -413,7 +413,7 @@
\begin{onlyenv}<2->
\begin{alertblock}{Example: don't! Everything in one long function}
\begin{multicols}{2}
\begin{cppcode*}{gobble=6}
\begin{cppcode*}{}
unsigned int runJob() {
// Step 1: data
Data data;
Expand All @@ -430,7 +430,7 @@
for (....) {
\end{cppcode*}
\columnbreak
\begin{cppcode*}{gobble=6,firstnumber=last}
\begin{cppcode*}{firstnumber=last}
if (...) {
data.erase(...);
}
Expand Down
2 changes: 1 addition & 1 deletion talk/basicconcepts/references.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
\end{block}

\begin{exampleblock}{Example:}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
int i = 2;
int &iref = i; // access to i
iref = 3; // i is now 3
Expand Down
8 changes: 4 additions & 4 deletions talk/basicconcepts/scopesnamespaces.tex
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
\item They can be embedded to create hierarchies (separator is '::')
\end{itemize}
\begin{multicols}{2}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
int a;
namespace n {
int a; // no clash
Expand All @@ -138,7 +138,7 @@
}
\end{cppcode*}
\columnbreak
\begin{cppcode*}{gobble=2,firstnumber=14}
\begin{cppcode*}{firstnumber=14}
namespace p { // reopen p
void f() {
p::a = 6;
Expand Down Expand Up @@ -207,7 +207,7 @@
\end{itemize}
\end{block}
\begin{alertblock}{Supersedes static}
\begin{cppcode*}{gobble=2,firstnumber=4}
\begin{cppcode*}{firstnumber=4}
static int localVar; // equivalent C code
\end{cppcode*}
\end{alertblock}
Expand All @@ -226,7 +226,7 @@
\end{cppcode*}
\end{alertblock}
\begin{alertblock}{Never use in headers at global scope!}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
#include "PoorlyWritten.h" // using namespace std;
struct array { ... };
array a; // Error: name clash with std::array
Expand Down
4 changes: 2 additions & 2 deletions talk/concurrency/atomic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
\end{itemize}
\end{block}
\begin{exampleblock}{}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
int a{0};
std::thread t1([&]{ std::atomic_ref<int> r{a}; r++;});
std::thread t2([&]{ std::atomic_ref{a}++; });
Expand All @@ -106,7 +106,7 @@
\end{cppcode*}
\end{exampleblock}
\begin{alertblock}{Don't mix concurrent atomic and non-atomic access}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
std::thread t3([&]{ std::atomic_ref{a}++; });
a += 2; // data race
t3.join();
Expand Down
4 changes: 2 additions & 2 deletions talk/concurrency/condition.tex
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
\end{overprint}

\begin{alertblock}{Na\"ive waiting}
\begin{cppcode*}{gobble=2,highlightlines=3}
\begin{cppcode*}{highlightlines=3}
auto processData = [&](){
std::unique_lock<std::mutex> lock{mutex};
cond.wait(lock, [&](){ return data.isReady(); });
Expand All @@ -101,7 +101,7 @@
\end{block}

\begin{exampleblock}{Correct waiting}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
auto processData = [&](){
{
std::unique_lock<std::mutex> lock{mutex};
Expand Down
6 changes: 3 additions & 3 deletions talk/concurrency/mutexes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
\end{itemize}
\end{goodpractice}
\begin{exampleblock}{}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
void function(...) {
// uncritical work ...
{
Expand Down Expand Up @@ -210,7 +210,7 @@
\end{itemize}
\end{block}
\begin{exampleblock}{}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
Data data; std::shared_mutex mutex;
auto reader = [&](){
std::shared_lock lock{mutex};
Expand All @@ -236,7 +236,7 @@
\end{itemize}
\end{block}
\begin{exampleblock}{}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
void worker(const int id, std::ostream & os);
void func() {
std::osyncstream synccout1{std::cout};
Expand Down
4 changes: 2 additions & 2 deletions talk/concurrency/threadsasync.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
\end{block}

\begin{exampleblock}{Example code}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
void foo() {...}
void bar() {...}
int main() {
Expand Down Expand Up @@ -59,7 +59,7 @@
\end{goodpractice}

\begin{exampleblock}{Example with jthread}
\begin{cppcode*}{gobble=2}
\begin{cppcode*}{}
void foo() {...}
void bar() {...}
int main() {
Expand Down
Loading