SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
A brief overview of C++17
Daniel Eriksson
Table of contents
● The standardization process, the committee
● C++ Standards
● The current status of the standardization process
● New language features
● New features in the standard libraries
● References
The standardization process
● A Commitee under ISO/IEC so multiple companies can co-operate and define
the language
● Work Group 21 (Google for wg21)
● Info on isocpp.org
○ Community site for publicizing for publicizing activity
● Work with Technical Specifications, TS:s
C++ Standards
● 1998
● 2003 TC1
● 2011
● 2014
● 2017
The Current Status
● Builds on C++14
● Significant library update
○ The additions and changes to the libraries are the biggest part of the new standard.
● Modest language update
● The standard has been agreed upon
● Will now be reviewed by ISO
● Expected release by the end of 2017
New language features
Attributes
● [[fallthrough]] a case without breaking
● [[nodiscard]] warns on ignored function results
● [[maybe_unused]]
● Grammar supports attributes on namespaces
○ namespace std::relops [[deprecated]] { …. }
● Grammars supports attributes on enumeratiors
○ enum MyEnum {old_name [[deprecated]], new_name ]
New Language Features
Examples
● [[maybe_unsued]] int f() {} // Won’t issue warning if return value is not
catched.
● [[nodiscard]] int f() {} // Will issue warning if return value is not catched.
● Alos deducted from type:
○ struct [[nodiscard]] MyStruct {};
○ MyStruct f() {}; // Will give compiler warning if return value is not handled.
New Language Features
Lamda Expressions
● constexpr lamda expressions
● It is now possible to caputre a copy of this, e.g *this
New Language Features
Structured Bindings
● Declare multiple variables, bound by function result
○ auto [x, y] = *map.find(key) // Returns a pair
● Functions can return
○ An aggregate
○ an arry-by-reference
○ something that supports the tuple protocol: array, pair or tuple
● Works anywhere an initialization may be performed
for (auto& [first, second] : myMap) {
// use firts and secon
}
New Features In The Standard Libraries
● Multicore support and Parallelism 1
● Math functions
● Extended vocabulary
● Text Handling
● Filesystem
● Smart Pointers
Parallelism
Distinction between parallelism and concurrency
● Parallelism
○ Simultaneously executing many copies of the same task to speed a single computation
● Concurrency
○ Performing multiple actions at the same time, often to improve latency
Parallelism
● Added execution_policy overload to most functions in the <algorithm> and <numeric>
headers
● Almost all of the algorithms in the standard library now how a “paralliezed” version
● Excpet
○ Random nubers
○ Heap opertaions (other than is_hep and is_heap_until)
○ permutations operations
○ copy_backwards, move_backward, lowe_bound, upper_bound, equal_range,
binary_search, accumulate, partial_sum, iota
● Added some new
○ exclusive_scan
○ inclusive_scan
○ transform_reduce
○ redue
Parallellism
Execution policies
● std::execution::seq
● std::execution::par
● std::execution::par_unseq
Math functions
● Adopted all of ISO 29124 (extensions to C++)
○ > 20 mathematical special functions
○ Bessel functions, beta function, riemann zeta etc
● hypot(x, y, z)
● gcd(a, b)
● lcm(a, b)
● A sampling function
○ sample(begin, end, out_iter, nSamples, rgb)
pair and tuple
● Unpack tuple arguments into a function call
○ apply(func, tuple{1, “two”, 3.14});
● Construct and object by unpacking a tuple
○ auto x = tuple{1, “two”, 3.14}
○ auto y = make_from_tuple<MyTYpe>(x);
Extended vocabulary
● Vocabulary types are the kind of types you would like to use in your interfaces
● Good with standardized vocabulary between libraries (for example)
● Already present
○ pair, tuple, array already in
● New ones
○ optinal<T>
○ any
○ variant<Types…>
○ string_view
optional<T>
#include <variant>
#include <string>
#include <string>
#include <iostream>
#include <optional>
// optional can be used as the return type of a factory that may fail
std::optional<std::string> create(bool b) {
if(b)
return "Godzilla";
else
return {};
}
int main()
{
std::cout << "create(false) returned "
<< create(false).value_or("empty") << 'n';
// optional-returning factory functions are usable as conditions of while and if
if(auto str = create(true)) {
std::cout << "create(true) returned " << *str << 'n';
}
}
variant<TYPES…>
#include <variant>
#include <string>
int main()
{
std::variant<int, float> v, w;
v = 12; // v contains int
int i = std::get<int>(v);
w = std::get<int>(v);
w = std::get<0>(v); // same effect as the previous line
w = v; // same effect as the previous line
// std::get<double>(v); // error: no double in [int, float]
// std::get<3>(v); // error: valid index values are 0 and 1
try {
std::get<float>(w); // w contains int, not float: will throw
}
catch (std::bad_variant_access&) {}
std::variant<std::string> v("abc"); // converting constructors work when unambiguous
v = "def"; // converting assignment also works when unambiguous
}
any
● Can hold any value as long as it is copy constructible
● Like varian except that it does not know what type it holds
● Will have to use any_cast to retrieve the value
any
int main()
{
boost::any a = 1;
std::cout << std::any_cast<int>(a) << 'n';
a = 3.14;
std::cout << std::any_cast<double>(a) << 'n';
a = true;
std::cout << std::boolalpha << std::any_cast<bool>(a) << 'n';
}
string_view
● string_view gives the ability to refer to an existing string in a non-owning way.
bool compare(const std::string& s1, const std::string& s2)
{
// do some comparisons between s1 and s2
}
int main()
{
std::string str = "this is my input string";
bool r1 = compare(str, "this is the first test string");
bool r2 = compare(str, "this is the second test string");
bool r3 = compare(str, "this is the third test string");
}
string_view
bool compare(std::string_view s1, std::string_view s2)
{
if (s1 == s2)
return true;
std::cout << '"' << s1 << "" does not match "" << s2 << ""n";
return false;
}
int main()
{
std::string str = "this is my input string";
compare(str, "this is the first test string");
compare(str, "this is the second test string");
compare(str, "this is the third test string");
return 0;
}
string_view
● In the last example only str is allocated.
● It is also possible to create string_view from a substring of a string.
○ The string_view points into the original string rather than to allocate a new string
○ string_view holds a pointer to a string and a size
Filesystem
● std::filesystem
● Specification based on POSIX standard semantics
○ NO protection against file system data races
● Uses system_error reporting introduced in C++11
● Functions and iterators to navigate a filesystem
● Functions to create, manipulate and query files (including directories and
symlinks)
Further Changes And Additions
● Smart pointers
● Allocators
● Memory Resources
Library Features Removed
● auto_ptr => Use unique_ptr
● bind1st, bind2nd, men_fun, men_fun_ref, ptr_fun, unary_function,
binary_funciton
● random_shuffle
References
● Alisdair Meredith
○ C++17 in Breadth Part 1
○ C++17 in Breadth Part 2
● isocpp.org
● cppreference.com

Contenu connexe

Tendances

DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright Andrei Alexandrescu
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()daewon jeong
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminarygo-lang
 
Basic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersBasic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersJen Yee Hong
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 Sumant Tambe
 
Introduction to JQ
Introduction to JQIntroduction to JQ
Introduction to JQKnoldus Inc.
 
2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - english2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - englishJen Yee Hong
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
 
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetDConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetAndrei Alexandrescu
 
Алексей Кутумов, Вектор с нуля
Алексей Кутумов, Вектор с нуляАлексей Кутумов, Вектор с нуля
Алексей Кутумов, Вектор с нуляSergey Platonov
 
Parsers Combinators in Scala, Ilya @lambdamix Kliuchnikov
Parsers Combinators in Scala, Ilya @lambdamix KliuchnikovParsers Combinators in Scala, Ilya @lambdamix Kliuchnikov
Parsers Combinators in Scala, Ilya @lambdamix KliuchnikovVasil Remeniuk
 
C++17 std::filesystem - Overview
C++17 std::filesystem - OverviewC++17 std::filesystem - Overview
C++17 std::filesystem - OverviewBartlomiej Filipek
 
jq: JSON - Like a Boss
jq: JSON - Like a Bossjq: JSON - Like a Boss
jq: JSON - Like a BossBob Tiernay
 
An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1Ganesh Samarthyam
 
Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++Sumant Tambe
 
Let's talks about string operations in C++17
Let's talks about string operations in C++17Let's talks about string operations in C++17
Let's talks about string operations in C++17Bartlomiej Filipek
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 

Tendances (20)

DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
 
Java 7
Java 7Java 7
Java 7
 
Basic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersBasic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmers
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012
 
Introduction to JQ
Introduction to JQIntroduction to JQ
Introduction to JQ
 
2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - english2018 cosup-delete unused python code safely - english
2018 cosup-delete unused python code safely - english
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetDConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
 
Алексей Кутумов, Вектор с нуля
Алексей Кутумов, Вектор с нуляАлексей Кутумов, Вектор с нуля
Алексей Кутумов, Вектор с нуля
 
Parsers Combinators in Scala, Ilya @lambdamix Kliuchnikov
Parsers Combinators in Scala, Ilya @lambdamix KliuchnikovParsers Combinators in Scala, Ilya @lambdamix Kliuchnikov
Parsers Combinators in Scala, Ilya @lambdamix Kliuchnikov
 
C++17 std::filesystem - Overview
C++17 std::filesystem - OverviewC++17 std::filesystem - Overview
C++17 std::filesystem - Overview
 
Towards hasktorch 1.0
Towards hasktorch 1.0Towards hasktorch 1.0
Towards hasktorch 1.0
 
Vocabulary Types in C++17
Vocabulary Types in C++17Vocabulary Types in C++17
Vocabulary Types in C++17
 
jq: JSON - Like a Boss
jq: JSON - Like a Bossjq: JSON - Like a Boss
jq: JSON - Like a Boss
 
An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1An Overview Of Standard C++Tr1
An Overview Of Standard C++Tr1
 
Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++
 
Let's talks about string operations in C++17
Let's talks about string operations in C++17Let's talks about string operations in C++17
Let's talks about string operations in C++17
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 

Similaire à Brief overview of new C++17 features

TEMPLATES IN JAVA
TEMPLATES IN JAVATEMPLATES IN JAVA
TEMPLATES IN JAVAMuskanSony
 
Custom Pregel Algorithms in ArangoDB
Custom Pregel Algorithms in ArangoDBCustom Pregel Algorithms in ArangoDB
Custom Pregel Algorithms in ArangoDBArangoDB Database
 
JavaScript: Patterns, Part 2
JavaScript: Patterns, Part  2JavaScript: Patterns, Part  2
JavaScript: Patterns, Part 2Chris Farrell
 
李建忠、侯捷设计模式讲义
李建忠、侯捷设计模式讲义李建忠、侯捷设计模式讲义
李建忠、侯捷设计模式讲义yiditushe
 
Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingRichardWarburton
 
Internal Anatomy of an Update
Internal Anatomy of an UpdateInternal Anatomy of an Update
Internal Anatomy of an UpdateMongoDB
 
Design Patterns in Modern C++
Design Patterns in Modern C++Design Patterns in Modern C++
Design Patterns in Modern C++Dmitri Nesteruk
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196Mahmoud Samir Fayed
 
(3) cpp procedural programming
(3) cpp procedural programming(3) cpp procedural programming
(3) cpp procedural programmingNico Ludwig
 
Fantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and JavascriptFantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and JavascriptKamil Toman
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAhmed Salama
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189Mahmoud Samir Fayed
 

Similaire à Brief overview of new C++17 features (20)

TEMPLATES IN JAVA
TEMPLATES IN JAVATEMPLATES IN JAVA
TEMPLATES IN JAVA
 
Dart workshop
Dart workshopDart workshop
Dart workshop
 
Custom Pregel Algorithms in ArangoDB
Custom Pregel Algorithms in ArangoDBCustom Pregel Algorithms in ArangoDB
Custom Pregel Algorithms in ArangoDB
 
JavaScript: Patterns, Part 2
JavaScript: Patterns, Part  2JavaScript: Patterns, Part  2
JavaScript: Patterns, Part 2
 
李建忠、侯捷设计模式讲义
李建忠、侯捷设计模式讲义李建忠、侯捷设计模式讲义
李建忠、侯捷设计模式讲义
 
What's New in C++ 11?
What's New in C++ 11?What's New in C++ 11?
What's New in C++ 11?
 
Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional Programming
 
Java 8
Java 8Java 8
Java 8
 
Golang dot-testing-lite
Golang dot-testing-liteGolang dot-testing-lite
Golang dot-testing-lite
 
Oops lecture 1
Oops lecture 1Oops lecture 1
Oops lecture 1
 
Internal Anatomy of an Update
Internal Anatomy of an UpdateInternal Anatomy of an Update
Internal Anatomy of an Update
 
Design Patterns in Modern C++
Design Patterns in Modern C++Design Patterns in Modern C++
Design Patterns in Modern C++
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196
 
(3) cpp procedural programming
(3) cpp procedural programming(3) cpp procedural programming
(3) cpp procedural programming
 
Should i Go there
Should i Go thereShould i Go there
Should i Go there
 
Fantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and JavascriptFantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and Javascript
 
C
CC
C
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189
 

Dernier

Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 

Dernier (20)

Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 

Brief overview of new C++17 features

  • 1. A brief overview of C++17 Daniel Eriksson
  • 2. Table of contents ● The standardization process, the committee ● C++ Standards ● The current status of the standardization process ● New language features ● New features in the standard libraries ● References
  • 3. The standardization process ● A Commitee under ISO/IEC so multiple companies can co-operate and define the language ● Work Group 21 (Google for wg21) ● Info on isocpp.org ○ Community site for publicizing for publicizing activity ● Work with Technical Specifications, TS:s
  • 4. C++ Standards ● 1998 ● 2003 TC1 ● 2011 ● 2014 ● 2017
  • 5. The Current Status ● Builds on C++14 ● Significant library update ○ The additions and changes to the libraries are the biggest part of the new standard. ● Modest language update ● The standard has been agreed upon ● Will now be reviewed by ISO ● Expected release by the end of 2017
  • 6.
  • 7. New language features Attributes ● [[fallthrough]] a case without breaking ● [[nodiscard]] warns on ignored function results ● [[maybe_unused]] ● Grammar supports attributes on namespaces ○ namespace std::relops [[deprecated]] { …. } ● Grammars supports attributes on enumeratiors ○ enum MyEnum {old_name [[deprecated]], new_name ]
  • 8. New Language Features Examples ● [[maybe_unsued]] int f() {} // Won’t issue warning if return value is not catched. ● [[nodiscard]] int f() {} // Will issue warning if return value is not catched. ● Alos deducted from type: ○ struct [[nodiscard]] MyStruct {}; ○ MyStruct f() {}; // Will give compiler warning if return value is not handled.
  • 9. New Language Features Lamda Expressions ● constexpr lamda expressions ● It is now possible to caputre a copy of this, e.g *this
  • 10. New Language Features Structured Bindings ● Declare multiple variables, bound by function result ○ auto [x, y] = *map.find(key) // Returns a pair ● Functions can return ○ An aggregate ○ an arry-by-reference ○ something that supports the tuple protocol: array, pair or tuple ● Works anywhere an initialization may be performed for (auto& [first, second] : myMap) { // use firts and secon }
  • 11. New Features In The Standard Libraries ● Multicore support and Parallelism 1 ● Math functions ● Extended vocabulary ● Text Handling ● Filesystem ● Smart Pointers
  • 12. Parallelism Distinction between parallelism and concurrency ● Parallelism ○ Simultaneously executing many copies of the same task to speed a single computation ● Concurrency ○ Performing multiple actions at the same time, often to improve latency
  • 13. Parallelism ● Added execution_policy overload to most functions in the <algorithm> and <numeric> headers ● Almost all of the algorithms in the standard library now how a “paralliezed” version ● Excpet ○ Random nubers ○ Heap opertaions (other than is_hep and is_heap_until) ○ permutations operations ○ copy_backwards, move_backward, lowe_bound, upper_bound, equal_range, binary_search, accumulate, partial_sum, iota ● Added some new ○ exclusive_scan ○ inclusive_scan ○ transform_reduce ○ redue
  • 14. Parallellism Execution policies ● std::execution::seq ● std::execution::par ● std::execution::par_unseq
  • 15. Math functions ● Adopted all of ISO 29124 (extensions to C++) ○ > 20 mathematical special functions ○ Bessel functions, beta function, riemann zeta etc ● hypot(x, y, z) ● gcd(a, b) ● lcm(a, b) ● A sampling function ○ sample(begin, end, out_iter, nSamples, rgb)
  • 16. pair and tuple ● Unpack tuple arguments into a function call ○ apply(func, tuple{1, “two”, 3.14}); ● Construct and object by unpacking a tuple ○ auto x = tuple{1, “two”, 3.14} ○ auto y = make_from_tuple<MyTYpe>(x);
  • 17. Extended vocabulary ● Vocabulary types are the kind of types you would like to use in your interfaces ● Good with standardized vocabulary between libraries (for example) ● Already present ○ pair, tuple, array already in ● New ones ○ optinal<T> ○ any ○ variant<Types…> ○ string_view
  • 18. optional<T> #include <variant> #include <string> #include <string> #include <iostream> #include <optional> // optional can be used as the return type of a factory that may fail std::optional<std::string> create(bool b) { if(b) return "Godzilla"; else return {}; } int main() { std::cout << "create(false) returned " << create(false).value_or("empty") << 'n'; // optional-returning factory functions are usable as conditions of while and if if(auto str = create(true)) { std::cout << "create(true) returned " << *str << 'n'; } }
  • 19. variant<TYPES…> #include <variant> #include <string> int main() { std::variant<int, float> v, w; v = 12; // v contains int int i = std::get<int>(v); w = std::get<int>(v); w = std::get<0>(v); // same effect as the previous line w = v; // same effect as the previous line // std::get<double>(v); // error: no double in [int, float] // std::get<3>(v); // error: valid index values are 0 and 1 try { std::get<float>(w); // w contains int, not float: will throw } catch (std::bad_variant_access&) {} std::variant<std::string> v("abc"); // converting constructors work when unambiguous v = "def"; // converting assignment also works when unambiguous }
  • 20. any ● Can hold any value as long as it is copy constructible ● Like varian except that it does not know what type it holds ● Will have to use any_cast to retrieve the value
  • 21. any int main() { boost::any a = 1; std::cout << std::any_cast<int>(a) << 'n'; a = 3.14; std::cout << std::any_cast<double>(a) << 'n'; a = true; std::cout << std::boolalpha << std::any_cast<bool>(a) << 'n'; }
  • 22. string_view ● string_view gives the ability to refer to an existing string in a non-owning way. bool compare(const std::string& s1, const std::string& s2) { // do some comparisons between s1 and s2 } int main() { std::string str = "this is my input string"; bool r1 = compare(str, "this is the first test string"); bool r2 = compare(str, "this is the second test string"); bool r3 = compare(str, "this is the third test string"); }
  • 23. string_view bool compare(std::string_view s1, std::string_view s2) { if (s1 == s2) return true; std::cout << '"' << s1 << "" does not match "" << s2 << ""n"; return false; } int main() { std::string str = "this is my input string"; compare(str, "this is the first test string"); compare(str, "this is the second test string"); compare(str, "this is the third test string"); return 0; }
  • 24. string_view ● In the last example only str is allocated. ● It is also possible to create string_view from a substring of a string. ○ The string_view points into the original string rather than to allocate a new string ○ string_view holds a pointer to a string and a size
  • 25. Filesystem ● std::filesystem ● Specification based on POSIX standard semantics ○ NO protection against file system data races ● Uses system_error reporting introduced in C++11 ● Functions and iterators to navigate a filesystem ● Functions to create, manipulate and query files (including directories and symlinks)
  • 26. Further Changes And Additions ● Smart pointers ● Allocators ● Memory Resources
  • 27. Library Features Removed ● auto_ptr => Use unique_ptr ● bind1st, bind2nd, men_fun, men_fun_ref, ptr_fun, unary_function, binary_funciton ● random_shuffle
  • 28. References ● Alisdair Meredith ○ C++17 in Breadth Part 1 ○ C++17 in Breadth Part 2 ● isocpp.org ● cppreference.com