Loading…
CppCon 2018 has ended
• Object Model [clear filter]
Monday, September 24
 

15:15 PDT

The Nightmare of Initialization in C++
After introducing uniform initialization with C++11, there are at least 5 ways in C++ to initialize an object.
Each have them has different rules, different effects, and different usage depending on the context and goals.
The situation is so confusing that today nobody can tell anymore which type of initialization to teach to beginners.
That's nothing but a disaster.

This talk will discuss the different forms of initialization, compare them to know when to use which, discuss what changed with C++14 and C++17 and what still has to change, and finally what to teach now to beginners.
I promise a source of trouble and discussion.

Speakers
avatar for Nicolai Josuttis

Nicolai Josuttis

IT Communication
Nicolai Josuttis (www.josuttis.com) is well-known in the community for his authoritative books and talks. For more than 20 years he has been a member of the C++ Standard Committee. He is the author of several worldwide best-sellers, including:- C++20: The Complete Guide- C++17: The... Read More →


Monday September 24, 2018 15:15 - 16:15 PDT
Steamboat (403)
  • Object Model

16:45 PDT

Surprises in Object Lifetime
One of the main defining features of C++ is that of well defined object lifetime. We know that when a scope exits any local variables will be properly cleaned up. This is something that we rely upon and use regularly for the management of resources (ie RAII).

However, there are some corners of the language that challenge our understanding of object lifetime. I have been teaching classes on understanding object lifetime for over a year now and some of these places continue to surprise my students and have even surprised me.

We will explore these corners of C++ and ask if they cause enough concern that the language features should not be used, or if they are still worth the price? We will also ponder if these can be considered mistakes in the language or just side effects of a useful feature. We will also explore when and how the compiler and analyzers can warn on these issues.

Speakers
avatar for Jason Turner

Jason Turner

Trainer/Speaker/YouTuber, Jason Turner
Jason is host of the YouTube channel C++Weekly, co-host emeritus of the podcast CppCast, author of C++ Best Practices, and author of the first casual puzzle books designed to teach C++ fundamentals while having fun!


Monday September 24, 2018 16:45 - 17:45 PDT
Aspen Highlands Hall (1st Floor)
  • Object Model
 
Tuesday, September 25
 

14:00 PDT

Woes of Scope Guards and Unique Resource - 5+ years in the making
C++ major benefit is its deterministic lifetime model of variables and values. This lead to the RAII (resource-acquisition is initialization) idiom that is essential for resource safety and less leakage. Some standard library classes already implement RAII for specific cases, such as heap-allocated pointers, mutex locking or file-I/O.

While some "mis"-uses of unique_ptr are recommended as a general RAII wrapper, those uses sometimes fail to be general enough. This lead Andrew Sandoval to specify a unique resource wrapper for the standard libary in 2013 (N3677). This talk tells the story how the author helped shepherding that mechanism through at least 12 revisions to make it into the standard library, which might be achieved while CPPCon runs, or not yet (hopes are high).

Implementing a RAII wrapper seems trivial, just implement a constructor and destructor, but doing so in generic ways is hard and tricky. Even with simple DIY solutions, interesting effects lurk and can lead to surprises also when using the generic solutions potentially provided by C++20.


Speakers
avatar for Peter Sommerlad

Peter Sommerlad

founder, Better Software: Consulting, Training, Reviews
Peter Sommerlad was director of IFS Institute for Software at FHO/HSR Rapperswil, Switzerland. Peter is co-author of the books POSA Vol.1 and Security Patterns and contributed to "97 things every programmer should know". His goal is to make software simpler and safer by Decremental... Read More →


Tuesday September 25, 2018 14:00 - 15:00 PDT
Winter Park (406)
  • Object Model

15:15 PDT

RVO is Harder than it Looks: the story of -Wreturn-std-move
Join Arthur O'Dwyer on a deep dive into Return Value Optimization and related topics.

Even C++03 allowed the compiler to "elide" copy construction in certain cases. We'll start with an explanation of the calling convention on a typical machine, showing where the mysterious "return slot" lives, and why it makes sense that C++03 allowed copy elision in certain special cases (but not others). Then we'll show how C++11 (and a subsequent defect report) upped the game by quietly turning the remaining copies into moves, so that the commonly received wisdom these days is that `return std::move(x)` is never necessary and often a pessimization.

...Or is it? We'll show some real-world examples where `return x` quietly copies a large object instead of moving it. We'll explain the little-known notion of a "converting constructor", contrast it with "conversion operator", and show the precise way in which C++17 drops the ball on these examples. Finally, Arthur implemented a Clang compiler warning to detect and suggest fixes for problematic return statements; he'll walk through the relatively painless process of creating that diagnostic, and perhaps inspire you to contribute to Clang yourself!

Speakers
avatar for Arthur O'Dwyer

Arthur O'Dwyer

C++ Trainer
Arthur O'Dwyer is the author of "Mastering the C++17 STL" (Packt 2017) and of professional training courses such as "Intro to C++," "Classic STL: Algorithms, Containers, Iterators," and "The STL From Scratch." (Ask me about training your new hires!) Arthur is occasionally active on... Read More →


Tuesday September 25, 2018 15:15 - 15:45 PDT
Breckenridge Hall (1st Floor)
  • Object Model
 
Thursday, September 27
 

16:45 PDT

Initialization, Shutdown, and constexpr
It's easy to create an access a global object in C++, but doing so correctly and safely is unfortunately a bit tricky. But why?

This talk will take a close look at the various rules that govern when an object is safe to access, including storage duration, object lifetime, initialization, and program termination. We'll look at some safe idioms for creating global singletons that are justified by these rules. And we'll look at the relevant, helpful features added in various revisions of C++, such as constexpr constructors, and how they make the situation better.

Speakers
GF

Greg Falcon

Staff Software Engineer, Google
Greg Falcon is a Staff Software Engineer at Google, working on the Abseil C++ library.


Thursday September 27, 2018 16:45 - 17:45 PDT
Copper Mountain Theater (2nd Floor)
  • Object Model
 
Filter sessions
Apply filters to sessions.