# from **Modern** to # ***Unbelievably Modern*** # **C++** ## Coral Kashri, Solidus & ## Daisy Hollman, Google ### CoreC++ 2023-06-06

Why would YOU want to be here?

  • Currently working with C++11/14/17 and unaware of newer standard abilities.
  • Learn about the abilities you might be unaware of (yet)
  • Upgrading is easier when performed step by step

Why would you NOT want to be here?

  • You don't care about bugs in your codebase
  • You don't care about long development times
  • You don't want to use the most modern optimizations
  • You believe in complicated solutions, even when easier ones available

What will we talk about?

  • Code written in C++11/14 vs. C++17
  • Code written in C++11/14/17 vs. C++20
  • How to prepare to and eventually migrate forward? (S~C~A~R~Y but E-A-S-Y!)
  • [Bonus] Interesting C++23 features

Extracting Values From Pair / Tuple (C++11 / 14)

Structured Binding (C++17)

If statements (C++11 / 14)


					
                        

If & Switch statements with initializer (C++17)

If statements on compile time information (C++11 / 14)


					

If constexpr (C++17)

Unions (C++11 / 14)


					

std::variant (C++17)

std::variant & std::visit (C++17)

There is a Return Value! (C++11 / 14)

[[nodiscard]] (C++17)

std::string substr (C++11 / 14)


					

std::string_view (C++17)

Variadic Templates (C++11 / 14)


						

Variadic Templates - Solution Issue

Fold-Expressions (C++17)

Fold-Expressions (C++17) - Solution Issue

C++17 Features - So Far

  • Structure Binding (auto [&a, &b] = ...)
  • If with initializer
  • If constexpr
  • std::variant & std::visit
  • [[nodiscard]]
  • std::string_view
  • fold-expressions

More C++17 Features

  • Guaranteed copy elision
  • Class template argument deduction
  • Non-type template parameters declared with auto
  • Simplified nested namespaces
  • And more!

What will we talk about?

  • Code written in C++11/14 vs. C++17
  • Code written in C++11/14/17 vs. C++20
  • How to prepare to and eventually migrate forward? (S~C~A~R~Y but E-A-S-Y!)
  • [Bonus] Interesting C++23 features

Sub-Array (C++11 / 14 / 17)


					

std::span (C++20)

std::size (C++11 / 14 / 17)


					

std::ssize - signed size (C++20)

Concat Strings (C++11 / 14 / 17)


						

External Library: fmt::format

std::format (C++20)

nodiscard (C++17)


					

nodiscard("description") (C++20)

Constraints In C++17


					

Concepts & Requires (C++20)

Interfaces (C++11 / 14 / 17)


					

Concepts as Interfaces (C++20)


					

C++20 Features - So Far

  • std::span
  • std::ssize
  • std::format / ranges 3rd party adoption
  • [[nodiscard("Description")]]
  • Concepts as named constraints
  • Concepts as interface

More C++20 Features

  • Consteval
  • Designated initializers
  • [[likely]] & [[unlikely]]
  • [[no_unique_address]]
  • Modules
  • Coroutines
  • Three-way comparison operator <=>
  • And more!

What will we talk about?

  • Code written in C++11/14 vs. C++17
  • Code written in C++11/14/17 vs. C++20
  • How to prepare to and eventually migrate forward? (S~C~A~R~Y but E-A-S-Y!)
  • [Bonus] Interesting C++23 features

Migrating Forward

New Compilers - New Optimizations

When don't you want to move forward?

What will we talk about?

  • Code written in C++11/14 vs. C++17
  • Code written in C++11/14/17 vs. C++20
  • How to prepare to and eventually migrate forward? (S~C~A~R~Y but E-A-S-Y!)
  • [Bonus] Interesting C++23 features

subscript operator - operator[]

operator[] with multiple parameters (C++23)

More C++23 Features

  • std::mdspan
  • Deducing this
  • flat_map & flat_set
  • And more!
# Questions Time! ## From Modern to Unbelievably Modern C++ | | Coral Kashri, Solidus | Daisy Hollman, Google | | :--------------------------: | :-----------------------: | :------------------------------: | | ![](twitter-logo.png#center) | @koralkashri | @The_Whole_Daisy | | | coralkashri@gmail.com | cpp@dsh.fyi | | ![](linkedin.png#center) | Coral Kashri | (Not really on LinkedIn) |