SlideShare a Scribd company logo
C++17 introduction
A focustd ovtrvitw on tht ntxt rtvision of tht standard
C++ Standards

1998 - first standard

2003 - TC1

2011 - stcond standard

2014 - rtvistd standard

2017 - ntxt rtvision
Growth of Standard
Cort Library Anntx D Total
1998 309 356 12 776
2003 +6 +1 0 +10
2011 +108 +406 +8 +567
2014 -10 +28 0 +20
2017 +23 +175 0 +235
C++17 at a Glanct

Modtst languagt updatt: ~45 proposals

Mostly solvt frustrations

Tht big ntw idioms art for C++20

Significant library updatt: ~90 proposals

Cltaning txisting standard
Cort: brtaking changts

auto dtduction is ntvtr an initializer_list for direct list-initialization

auto x{y}; // now a copy of y

auto z{1, 2, 3}; // now ill-formed

Exctption sptcifications art part of tht function typt

void g1() noexcept;

void g2();

template<typename T> int f(T*, T*);

int x = f(g1, g2); // new error
Cort: languagt twtaks

Easily optn ntsttd namtspacts

namespace std::filesystem { class path; }

Initialization in if and switch stattmtnts

if (lock_guard<mutex> lk(mx); v.empty()) {

v.push_back(kInitialValue);

}

A dtfault trror mtssagt for static_assert

static_assert(std::is_same_v<T, U>);
Structurtd bindings

Dtclart multiplt variablts, bound to a function rtsult:

auto [n, ok] = map.emplace(42);

Works anywhtrt an initialization may bt ptrformtd

for (auto& [key, value] : map) {

// leads to more expressive code

}

Works with:

An aggrtgatt

An array-by-rtftrtnct

array, pair, or tuplt
Lambda txprtssions

C++14: Polymorphic lambda capturt (a.k.a. gtntric lambdas)

for_each(begin(v), end(v), [](const auto& x) { cout << x; });

C++14: Capturt initialization

auto a = make_unique<T>(42); // move-only

go.run([a = move(a)] { return *a; }); // transfer ownership to closure
Lambda txprtssions

C++17: constexpr lambda txprtssions

constexpr auto multiply = [](int a, int b){ return a * b; };

static_assert(multiply(6,7) == 42);

C++17: Capturt a copy of *this
Ttmplatts
Fold txprtssions: fold a ttmplatt paramtttr pack with a unary or

binary fold

bool all_of(Predicate pred, Args&&... args) {

return (pred(args) && ...);

}

bool any_of(Predicate pred, Args&&... args) {

return (... || pred(args));

}

bool none_of(Predicate pred, Args&&... args) {

return (true && ... && !pred(args));

}

if constexpr: if txprtssion fails, wt gtt a discardtd branch

that is not tvaluattd
if consttxpr
Avoids unntctssarily compltx stts of sptcialization or ovtrloads:

C++14:

template<typename T, std::enable_if_t<std::is_pointer<T>::value>* = nullptr>

auto get_value(T t) {

return *t;

}

template<typename T, std::enable_if_t<!std::is_pointer<T>::value>* = nullptr>

auto get_value(T t) {

return t;

}

C++17:

template<typename T>

auto get_value(T x) {

if constexpr (std::is_pointer_v<T>)

return *x; // deduces return type to int for T = int*

else

return x; // deduces return type to int for T = int

}
Cort: attributts

[[deprecated]]

[[fallthrough]] a cast without breaking

[[nodiscard]] warns on ignortd function rtsults

[[maybe_unused]] paramtttrs and variablts
Library: vocabulary typts

std::pair<T1, T2>

std::tuplt<Typts...>

std::array<T, N>

std::optional<T> A valut that may or may not bt prtstnt

std::any A typt-saft containtr for singlt valuts of any typt

std::variant<Types...> A typt-saft union

std::string_view A non-owning rtftrtnct to a string
Library: Multicort support

Paralltlism TS: Add execution_policy ovtrload to most functions

in tht <algorithm> and <numtric> htadtrs

atomic_int x;

for_each(execution::par, begin(v), end(v), [&x](int) { ++x; });

Concurrtncy

shared_mutex untimtd vtrsion of shared_timed_mutex

Variadic lock_guard
Library: Filtsysttm
Functions and iterators to navigate a filesystem in std::filesystem

Integration with std::system_error and std::error_code

Functions to create, manipulate and query files

namespace fs = std::filesystem;

fs::path p = fs::current_path() / "sandbox";

fs::create_directories(p / "from");

std::ofstream(p / "from/file1.txt").put('a');

fs::create_directory(p / "to");

fs::rename(p / "from/file1.txt", p / "to/file2.txt");

fs::remove_all(p);
Library: Typt traits

Typt traits variablt ttmplatts:

is_same_v complement to add_const_t

void_t: Ustd in ttmplatt mttaprogramming to dtttct ill-formtd

typts in SFINAE conttxt:

// primary template handles types that have no nested ::type

template<typename, typename = void_t<>>

struct has_type_member : false_type {};


// specialization recognizes types that do have a nested ::type

template<typename T>

struct has_type_member<T, void_t<typename T::type>> : true_type {};
Currtnt status
Thank you!

More Related Content

PPTX
PDF
Modern c++ (C++ 11/14)
PPTX
PPTX
C++ 11 Features
PDF
C++11 concurrency
PPTX
Summary of C++17 features
PDF
C++11
PDF
Le langage rust
Modern c++ (C++ 11/14)
C++ 11 Features
C++11 concurrency
Summary of C++17 features
C++11
Le langage rust

What's hot (20)

PDF
C++11 & C++14
PDF
Fun with Lambdas: C++14 Style (part 1)
PPTX
PPTX
Basic c++ programs
PDF
Modern C++
PPTX
C++11: Feel the New Language
PDF
C++11: Rvalue References, Move Semantics, Perfect Forwarding
PPTX
C++ theory
PDF
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
PPTX
Lambda Expressions in C++
PPTX
Fun with Lambdas: C++14 Style (part 2)
PPT
STL ALGORITHMS
PPTX
basics of c++
PPTX
Introduction to C++
PPTX
Idiomatic C++
PPT
Csc1100 lecture05 ch05
PPTX
Learning C++ - Functions in C++ 3
PPTX
Csc1100 lecture02 ch02-datatype_declaration
PPTX
Presentation on C++ Programming Language
DOCX
Type header file in c++ and its function
C++11 & C++14
Fun with Lambdas: C++14 Style (part 1)
Basic c++ programs
Modern C++
C++11: Feel the New Language
C++11: Rvalue References, Move Semantics, Perfect Forwarding
C++ theory
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
Lambda Expressions in C++
Fun with Lambdas: C++14 Style (part 2)
STL ALGORITHMS
basics of c++
Introduction to C++
Idiomatic C++
Csc1100 lecture05 ch05
Learning C++ - Functions in C++ 3
Csc1100 lecture02 ch02-datatype_declaration
Presentation on C++ Programming Language
Type header file in c++ and its function
Ad

Viewers also liked (20)

PDF
Web I - 05 - HTTP Protocol
PDF
Bjarne essencegn13
PDF
"Http protocol and other stuff" by Bipin Upadhyay
PPTX
HTTP Protocol Basic
PDF
C++17 - the upcoming revolution (Code::Dive 2015)/
PDF
Networking - TCP/IP stack introduction and IPv6
PPTX
Elements of C++11
PPTX
Database connectivity to sql server asp.net
PDF
C++11 Idioms @ Silicon Valley Code Camp 2012
PDF
C++14 Overview
PDF
C++ 11 Style : A Touch of Class
PPT
C# Tutorial MSM_Murach chapter-17-slides
PDF
C++11 smart pointers
PDF
Cpp17 and Beyond
PDF
Data structures / C++ Program examples
PDF
HTTPS: What, Why and How (SmashingConf Freiburg, Sep 2015)
PPTX
Http Vs Https .
PPTX
Introduction to HTTP protocol
PPTX
HyperText Transfer Protocol (HTTP)
Web I - 05 - HTTP Protocol
Bjarne essencegn13
"Http protocol and other stuff" by Bipin Upadhyay
HTTP Protocol Basic
C++17 - the upcoming revolution (Code::Dive 2015)/
Networking - TCP/IP stack introduction and IPv6
Elements of C++11
Database connectivity to sql server asp.net
C++11 Idioms @ Silicon Valley Code Camp 2012
C++14 Overview
C++ 11 Style : A Touch of Class
C# Tutorial MSM_Murach chapter-17-slides
C++11 smart pointers
Cpp17 and Beyond
Data structures / C++ Program examples
HTTPS: What, Why and How (SmashingConf Freiburg, Sep 2015)
Http Vs Https .
Introduction to HTTP protocol
HyperText Transfer Protocol (HTTP)
Ad

Similar to C++17 introduction - Meetup @EtixLabs (20)

PDF
Meetup C++ A brief overview of c++17
PPTX
C++17 now
PPTX
Modern C++
PPT
Glimpses of C++0x
PPTX
Gude for C++11 in Apache Traffic Server
PPTX
How to Adopt Modern C++17 into Your C++ Code
PPTX
How to Adopt Modern C++17 into Your C++ Code
PPT
What's New in C++ 11?
PDF
Beyond C++17
PPTX
Modern C++ Lunch and Learn
PDF
Антон Бикинеев, Writing good std::future&lt; C++ >
PDF
C++17 not your father’s c++
PPT
Gentle introduction to modern C++
PDF
C++ L02-Conversion+enum+Operators
PPTX
cbybalaguruswami-e-180803051831.pptx
PPTX
cbybalaguruswami-e-180803051831.pptx
PPTX
Whats New in Visual Studio 2012 for C++ Developers
PPTX
C++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptx
PDF
C++14 - Modern Programming for Demanding Times
PPT
OOP in C++
Meetup C++ A brief overview of c++17
C++17 now
Modern C++
Glimpses of C++0x
Gude for C++11 in Apache Traffic Server
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ Code
What's New in C++ 11?
Beyond C++17
Modern C++ Lunch and Learn
Антон Бикинеев, Writing good std::future&lt; C++ >
C++17 not your father’s c++
Gentle introduction to modern C++
C++ L02-Conversion+enum+Operators
cbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptx
Whats New in Visual Studio 2012 for C++ Developers
C++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptx
C++14 - Modern Programming for Demanding Times
OOP in C++

Recently uploaded (20)

PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
AI in Product Development-omnex systems
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Introduction to Artificial Intelligence
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Transform Your Business with a Software ERP System
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
System and Network Administration Chapter 2
PPTX
Essential Infomation Tech presentation.pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
medical staffing services at VALiNTRY
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Odoo Companies in India – Driving Business Transformation.pdf
Nekopoi APK 2025 free lastest update
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
AI in Product Development-omnex systems
CHAPTER 2 - PM Management and IT Context
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Odoo POS Development Services by CandidRoot Solutions
How to Migrate SBCGlobal Email to Yahoo Easily
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Introduction to Artificial Intelligence
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Design an Analysis of Algorithms I-SECS-1021-03
Transform Your Business with a Software ERP System
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
System and Network Administration Chapter 2
Essential Infomation Tech presentation.pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Softaken Excel to vCard Converter Software.pdf
medical staffing services at VALiNTRY
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...

C++17 introduction - Meetup @EtixLabs

  • 1. C++17 introduction A focustd ovtrvitw on tht ntxt rtvision of tht standard
  • 2. C++ Standards  1998 - first standard  2003 - TC1  2011 - stcond standard  2014 - rtvistd standard  2017 - ntxt rtvision
  • 3. Growth of Standard Cort Library Anntx D Total 1998 309 356 12 776 2003 +6 +1 0 +10 2011 +108 +406 +8 +567 2014 -10 +28 0 +20 2017 +23 +175 0 +235
  • 4. C++17 at a Glanct  Modtst languagt updatt: ~45 proposals  Mostly solvt frustrations  Tht big ntw idioms art for C++20  Significant library updatt: ~90 proposals  Cltaning txisting standard
  • 5. Cort: brtaking changts  auto dtduction is ntvtr an initializer_list for direct list-initialization  auto x{y}; // now a copy of y  auto z{1, 2, 3}; // now ill-formed  Exctption sptcifications art part of tht function typt  void g1() noexcept;  void g2();  template<typename T> int f(T*, T*);  int x = f(g1, g2); // new error
  • 6. Cort: languagt twtaks  Easily optn ntsttd namtspacts  namespace std::filesystem { class path; }  Initialization in if and switch stattmtnts  if (lock_guard<mutex> lk(mx); v.empty()) {  v.push_back(kInitialValue);  }  A dtfault trror mtssagt for static_assert  static_assert(std::is_same_v<T, U>);
  • 7. Structurtd bindings  Dtclart multiplt variablts, bound to a function rtsult:  auto [n, ok] = map.emplace(42);  Works anywhtrt an initialization may bt ptrformtd  for (auto& [key, value] : map) {  // leads to more expressive code  }  Works with:  An aggrtgatt  An array-by-rtftrtnct  array, pair, or tuplt
  • 8. Lambda txprtssions  C++14: Polymorphic lambda capturt (a.k.a. gtntric lambdas)  for_each(begin(v), end(v), [](const auto& x) { cout << x; });  C++14: Capturt initialization  auto a = make_unique<T>(42); // move-only  go.run([a = move(a)] { return *a; }); // transfer ownership to closure
  • 9. Lambda txprtssions  C++17: constexpr lambda txprtssions  constexpr auto multiply = [](int a, int b){ return a * b; };  static_assert(multiply(6,7) == 42);  C++17: Capturt a copy of *this
  • 10. Ttmplatts Fold txprtssions: fold a ttmplatt paramtttr pack with a unary or  binary fold  bool all_of(Predicate pred, Args&&... args) {  return (pred(args) && ...);  }  bool any_of(Predicate pred, Args&&... args) {  return (... || pred(args));  }  bool none_of(Predicate pred, Args&&... args) {  return (true && ... && !pred(args));  }  if constexpr: if txprtssion fails, wt gtt a discardtd branch  that is not tvaluattd
  • 11. if consttxpr Avoids unntctssarily compltx stts of sptcialization or ovtrloads:  C++14:  template<typename T, std::enable_if_t<std::is_pointer<T>::value>* = nullptr>  auto get_value(T t) {  return *t;  }  template<typename T, std::enable_if_t<!std::is_pointer<T>::value>* = nullptr>  auto get_value(T t) {  return t;  }  C++17:  template<typename T>  auto get_value(T x) {  if constexpr (std::is_pointer_v<T>)  return *x; // deduces return type to int for T = int*  else  return x; // deduces return type to int for T = int  }
  • 12. Cort: attributts  [[deprecated]]  [[fallthrough]] a cast without breaking  [[nodiscard]] warns on ignortd function rtsults  [[maybe_unused]] paramtttrs and variablts
  • 13. Library: vocabulary typts  std::pair<T1, T2>  std::tuplt<Typts...>  std::array<T, N>  std::optional<T> A valut that may or may not bt prtstnt  std::any A typt-saft containtr for singlt valuts of any typt  std::variant<Types...> A typt-saft union  std::string_view A non-owning rtftrtnct to a string
  • 14. Library: Multicort support  Paralltlism TS: Add execution_policy ovtrload to most functions  in tht <algorithm> and <numtric> htadtrs  atomic_int x;  for_each(execution::par, begin(v), end(v), [&x](int) { ++x; });  Concurrtncy  shared_mutex untimtd vtrsion of shared_timed_mutex  Variadic lock_guard
  • 15. Library: Filtsysttm Functions and iterators to navigate a filesystem in std::filesystem  Integration with std::system_error and std::error_code  Functions to create, manipulate and query files  namespace fs = std::filesystem;  fs::path p = fs::current_path() / "sandbox";  fs::create_directories(p / "from");  std::ofstream(p / "from/file1.txt").put('a');  fs::create_directory(p / "to");  fs::rename(p / "from/file1.txt", p / "to/file2.txt");  fs::remove_all(p);
  • 16. Library: Typt traits  Typt traits variablt ttmplatts:  is_same_v complement to add_const_t  void_t: Ustd in ttmplatt mttaprogramming to dtttct ill-formtd  typts in SFINAE conttxt:  // primary template handles types that have no nested ::type  template<typename, typename = void_t<>>  struct has_type_member : false_type {};   // specialization recognizes types that do have a nested ::type  template<typename T>  struct has_type_member<T, void_t<typename T::type>> : true_type {};