This document discusses various usability enhancements introduced in modern C++, including C++11/14/17. It covers topics such as auto type deduction, decltype, nullptr, range-based for loops, uniform initialization, lambda expressions, and more. The enhancements aim to improve code readability, reduce errors and increase developer productivity when programming in C++.
The document discusses various aspects of template type deduction in C++ including:
1. How the type T and the type of the parameter ParamType are deduced based on whether ParamType is a pointer/reference, universal reference, or neither.
2. How array arguments are handled differently when passed by value versus by reference in templates.
3. How function arguments are treated, with function types decaying to function pointers.
4. The differences between auto type deduction and template type deduction.
5. How decltype can be used to deduce types from expressions while preserving reference-ness.
The document discusses toolchains and cross toolchains. It defines a toolchain as a collection of tools including a C compiler, C libraries, and binary utilities. A cross toolchain is a toolchain configured to compile code for a platform other than the one on which the toolchain is running. The document outlines steps for building a cross toolchain, including obtaining kernel headers, building binary utilities, compilers, and libraries. It also discusses automated build tools like Crosstool and testing the generated cross toolchain.
The document is a tutorial on C++11 concurrency features such as asynchronous tasks, threads, promises, mutexes, and condition variables. It covers topics like spawning asynchronous tasks using std::async and std::thread, returning values from asynchronous tasks, passing parameters, handling exceptions, manually setting futures using std::promise and std::packaged_task, waiting for multiple futures, and using mutexes and lock guard templates for synchronization. Code examples are provided to illustrate the various concurrency features.
The document discusses Ethernet device drivers in Linux. It describes the driver architecture, Ethernet packet format, driver development process, and important data structures like net_device and sk_buff. It provides examples of initializing a driver, probing hardware, uploading/downloading data using callbacks, interrupt handling, and buffer management. The key steps are registering the driver, allocating network devices, setting callbacks, and using sk_buff objects to transfer packets between layers.
The document discusses various string handling, mathematical, and random number generation functions available in C++ library. It provides examples of functions like strlen(), strcpy(), strcmp(), sqrt(), pow(), randomize(), random(). It also provides programs to demonstrate the use of these functions for tasks like checking palindromes, searching strings, toggling case, generating random numbers in a given range.
Utah Code Camp, Spring 2016. http://utahcodecamp.com In this presentation I describe modern C++. Modern C++ assumes features introduced in the C++11/14 standard. An overview of the new features is presented and some idioms for mdoern C++ based on those features are presented.
The document discusses different types of loops in C programming: for loops, while loops, and do-while loops. For loops allow initialization of a variable, specify a condition, and how to increment the variable. While loops repeatedly execute code as long as a condition is true. Do-while loops are similar but check the condition at the bottom of the loop, so the code executes at least once. Examples of each loop type are provided.
The document discusses developing network device drivers for embedded Linux. It covers key topics like socket buffers, network devices, communicating with network protocols and PHYs, buffer management, and differences between Ethernet and WiFi drivers. The outline lists these topics and others like throughput and considerations. Prerequisites include C skills, Linux knowledge, and an understanding of networking and embedded driver development.
Exceptions are runtime errors that a program may encounter. There are two types: synchronous from faults in input data, and asynchronous from external events. Exception handling uses try, throw, and catch keywords. Code that may cause exceptions is placed in a try block. When an exception occurs it is thrown, and the catch block handles it to prevent program termination. Multiple catch blocks can handle different exception types, and a catch-all block uses ellipses to catch any exception.
C has been the most commonly used language. This slideshare is all about the introduction to Advanced C. You will learn the fundamentals and the problem solving skills. You will also get an idea on building algorithms and the conditions regarding it. There are also slides which will give knowledge about operators and their types. As a whole you will gain knowledge on three important fundamentals of C.
- C is a commonly used language for embedded systems that is portable, produces efficient code, and uses a fairly concise syntax.
- It was developed in the late 1960s and early 1970s and was influenced by the B programming language.
- C uses basic data types, functions, expressions, statements, and other constructs to provide powerful yet flexible programming capabilities while using relatively little memory.
The document discusses inline functions in C++. Inline functions allow code from a function to be pasted directly into the call site rather than executing a function call. This avoids overhead from calling and returning from functions. Good candidates for inline are small, simple functions called frequently. The document provides an example of a function defined with the inline keyword and the optimizations a compiler may perform after inlining. It also compares inline functions to macros and discusses where inline functions are best used.
C++11 introduced several new features for functions and lambdas including:
1. Lambda expressions that allow the definition of anonymous inline functions.
2. The std::function wrapper that allows functions and lambdas to be used interchangeably.
3. std::bind that binds arguments to function parameters for creating function objects.
These features improved support for functional programming patterns in C++.
GDB can debug programs by running them under its control. It allows inspecting and modifying program state through breakpoints, watchpoints, and examining variables and memory. GDB supports debugging optimized code, multi-threaded programs, and performing tasks like stepping, continuing, and backtracing through the call stack. It can also automate debugging through commands, scripts, and breakpoint actions.
Here is a C program to produce a spiral array as described in the task:
#include <stdio.h>
int main() {
int n = 5;
int arr[n][n];
int num = 1;
int rowBegin = 0;
int rowEnd = n-1;
int colBegin = 0;
int colEnd = n-1;
while(rowBegin <= rowEnd && colBegin <= colEnd) {
// Top row
for(int i=colBegin; i<=colEnd; i++) {
arr[rowBegin][i] = num++;
}
rowBegin++;
// Right column
for(int i=rowBegin;
C++17 introduced updates to both the C++ language and standard library. For the language, there were around 45 modest proposals that mostly solved frustrations from prior standards. Significant updates to the library included new vocabulary types like std::optional and std::string_view. C++17 also added features like structured bindings, if constexpr, and lambda improvements like constexpr lambdas and capture of *this. The filesystem library was standardized to provide OS-abstraction for file/directory operations.
10 Of The Best Books About TCP/IP And Networking
1.Internet Core Protocols: The Definitive Guide: Help for Network Administrators
2.Effective TCP/IP Programming: 44 Tips to Improve Your Network Programs
3.TCP/IP Explained
4.High-Speed Networks TCP/IP and ATM Design Principles
5.TCP/IP: Architecture, Protocols, and Implementation with IPv6 and IP
6.SNMP, SNMPv2, SNMPv3, and RMON 1 and 2
7.SNMP: A Guide to Network Management
8.TCP/IP Network Administration
9.Teach Yourself Tcp/Ip in 14 Days
10.UNIX Network Programming
The document provides an overview of Bjarne Stroustrup's views on the C++ programming language. Some key points:
1) C++ aims to provide performance, predictability, teachability, and readability while supporting systems programming, embedded systems, large systems, and both experts and novices.
2) C++ offers features like mapping to hardware, classes, inheritance, templates, and generic programming while not requiring a garbage collector for resource management.
3) Resource management in C++ relies on resource handles, RAII, and move semantics rather than a garbage collector. Templates and generic programming are designed to be as efficient and well-specified as traditional code.
This document provides an overview of new features introduced in C++11, including automatic variables, decltype, rvalue references, lambda functions, variadic templates, and the concurrency library. It discusses each feature in detail and provides examples. It also outlines compiler support for C++11 in different versions of Visual Studio and references additional learning resources on C++11.
A holistic view of how the web works, with an overview of the HTTP protocol.
Presented by me at null security group (http://null.co.in), Mumbai chapter meet on Aug' 27th.
The HTTP protocol is an application-level protocol used for distributed, collaborative, hypermedia information systems. It operates as a request-response protocol between clients and servers, with clients making requests using methods like GET and POST and receiving responses with status codes. Requests and responses are composed of text-based headers and messages to communicate metadata and content. Caching and cookies can be used to improve performance and maintain state in this otherwise stateless protocol.
C++17 - the upcoming revolution (Code::Dive 2015)/
The document discusses the history and development of the internet over the past 50 years, from its origins as a network created by the United States Department of Defense to support research and education, to its subsequent commercialization and global adoption driven by the creation of the World Wide Web in the early 1990s. It grew exponentially from being used primarily by academic and military institutions to becoming integrated into the daily lives of billions of people worldwide for communication, education, commerce, and entertainment.
C++11 introduced many new features including type deduction with auto, uniform initialization syntax, rvalue references and move semantics, improved enums, lambda expressions, and smart pointers. Type deduction with auto lets the compiler deduce the type of a variable based on its initializer. Uniform initialization uses curly braces {} and allows narrowing conversions only if explicitly cast. Rvalue references and move semantics allow moving an object to avoid expensive copies by leaving the source object in a valid but unspecified state.
The document discusses IPv6 and Mobile IPv6 fundamentals, new services, and applications. It begins with an introduction to TCP/IP and the Internet and then covers the OSI and TCP/IP reference models. It describes the physical, data link, network, transport, and application layers. It focuses on IPv6 features like addressing, autoconfiguration, and mobility support through Mobile IPv6. It also discusses new applications and challenges with the transition from IPv4 to IPv6.
This ppt will help those who are beginner in sql server, asp.net and C# and want to learn database connectivity. So i provide them the simpler code on this universe for their database enabled web or desktop application.
C++11 feels like a new language. Compared to its previous standards, C++11 packs more language features and libraries designed to make C++ programs easier to understand and faster. As the community is building up experience with the new features, new stylistic ways of using them are emerging. These styles (a.k.a. idioms) give the new language its unique flavor. This talk will present emerging idioms of using rvalue references -- a marquee feature of C++11 as many renowned experts call it. You will see how C++11 opens new possibilities to design class interfaces. Finally, you will learn some advanced use-cases of rvalue references which will likely make you feel something amiss in this flagship feature of C++11.
The document discusses principles of writing good C++ code. It begins by criticizing existing code examples as "ghastly style" that are difficult to understand and maintain. It advocates for a type-rich interface style with compact data structures and well-structured algorithms. The document also emphasizes writing code with modularity, effective resource management, and thread safety by default. The presentation provides examples demonstrating these principles using C++11 features like auto, type aliases, and literals.
This document provides an introduction to database programming and ADO.NET. It outlines the objectives and key concepts, including the hardware and software components of a client/server database system, how tables and records are organized in a relational database, common SQL statements, and the core ADO.NET classes like the connection, command, data adapter and dataset. It also covers topics like joining data from multiple tables, concurrency handling, and how ADO.NET objects can be created either from a data source or directly using code.
The document outlines requirements for an IT 211 Data Structures midterm. It includes 3 programming problems: 1) a program to track election results and declare a winner, 2) a program to count words, sentences, and paragraphs in input text, and 3) programs to convert between binary and decimal numbers recursively. It also provides lecture requirements on defining and implementing stacks, lists, queues, and pointers in C++.
A glimpse at some of the new features for the C++ programming languages that will be introduced by the upcoming C++17 Standard.
This talk was given at the Munich C++ User Group Meetup.
HTTPS: What, Why and How (SmashingConf Freiburg, Sep 2015)
When users use our sites, they put their faith in us. They trust we will keep their information from reaching others, believe we provided the information they see, and allow us to run (web) code on their devices. Using HTTPS to secure our conversations is a key part of maintaining this trust.
If that’s not motivation enough, the web’s giants are actively promoting HTTPS, requiring it for features such as HTTP2 & ServiceWorker, using it for search engine ranking and more. To make the most of the web, you need to use HTTPS.
This deck reviews what HTTPS is, discusses why you should prioritize using it, and cover some of the easiest (and most cost effective) steps to get started using HTTPS
Slides from my "Gentle Introduction to Modern C++" presentation from January 20, 2015 at the Dublin C/C++ User Group: www.meetup.com/cppdug/events/219787667/
The code examples are located here: https://github.com/mihaitodor/Presentations/tree/master/cppdug/20.01.2015
C++11 introduced several new features to C++ that support modern programming patterns like lambdas, smart pointers, and move semantics. Lambdas allow for anonymous inline functions, which improve code readability and eliminate the need for functor classes. Smart pointers like unique_ptr and shared_ptr make memory management safer and more straightforward using features like move semantics and RAII. C++11 also aims to bring C++ more in line with modern hardware by supporting multi-threading and higher level abstractions while maintaining performance.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
The document provides an overview of the C programming language. It begins by explaining that Objective-C extends standard ANSI C with object-oriented capabilities. It then discusses why C remains important today due to its use in libraries, operating systems, and as the base for many other popular languages. The document proceeds to cover basic C concepts like variables, data types, functions, flow control, pointers, memory allocation, and I/O parameters. It emphasizes that C provides high performance with a minimal footprint while abstracting away the CPU and memory.
This document provides an overview of C++ control statements, functions, and storage classes. It discusses various loops like while, for, and do-while loops. It also covers decision making statements such as if-else, if-else-if-else, switch statements, and unconditional statements like break, continue, and goto. The document then discusses functions, recursion, and inline functions. Finally, it summarizes different storage classes in C++ like auto, register, static, external, and mutable and provides examples of each.
The document provides information about C and C Sharp programming languages. It discusses the history, features, data types, loops, conditional statements, functions, arrays, pointers, object-oriented concepts like inheritance, encapsulation, polymorphism in both the languages. It also highlights some advantages of C Sharp over C like automatic memory management, no need of header files etc.
This document provides an introduction to the C programming language. It discusses fundamental C elements like data types, variables, constants, operators, and input/output functions. It explains how a basic C program is structured and compiled. Examples are provided to demonstrate simple C statements, arithmetic expressions, and how to write and run a first program that prints text. The key topics covered include basic syntax, program structure, data types, identifiers, operators, and input/output functions like printf() and scanf().
The document discusses various topics related to C language including:
- Benefits and features of C like low-level operations, structured programming, and modular programming
- Data types in C like fundamental types (char, int, float), derived types, and defining variables
- Structure of C functions including single-level and multiple-level functions
- Input-output functions in C like character-based (getc, putc), string-based (gets, puts)
The document discusses C++0x standard library extensions (TR1) and advanced C++ techniques. It provides an overview of new features in C++0x related to the core language like type inference, lambda functions, and rvalue references. It also discusses changes to the C++ standard library like tuples, hash tables, smart pointers, and other containers. The document is intended as course material covering these new C++0x features.
Functions And Header Files In C++ | Bjarne stroustrup
This document discusses functions and header/source files in C++. It covers declarations, definitions, and the differences between them. Declarations introduce names and specify types, while definitions also fully specify the entity. Declarations allow interfaces to be specified. Headers contain declarations to share interfaces between parts of a program. Functions are described as units of operation that can take parameters and return values. The document also discusses scopes, namespaces, and storage classes like static.
The document provides an overview of the C++ programming language. It discusses that C++ was created by Bjarne Stroustrup to provide Simula's facilities for program organization together with C's efficiency and flexibility for systems programming. The document outlines key C++ features like classes, templates, operator overloading, and exceptions. It also covers topics like class definitions, constructors, destructors, streams, and compiling/linking C++ programs.
The document provides suggestions for using various new C++11 language features in ATS coding, focusing on features that are most useful. It discusses nullptr, auto, range-based for loops, delegating constructors, prohibiting/defaulting methods, member initialization, override, explicit conversion operators, std::unique_ptr, lambdas, std::function, constexpr, and provides code examples for many of these features. The overall aim is to take advantage of new language features to improve ATS code without overusing them in a way that makes the code harder to understand.
what are loop in general
what is loop in c language
uses of loop in c language
types of loop in c language
program of loop in c language
syantax of loop in c language
operator overloading & type conversion in cpp over view || c++gourav kottawar
The document discusses operator overloading and type conversion in C++. It begins by defining operator overloading as giving special meanings to operators for user-defined types. It then covers overloading unary and binary operators using member functions and friend functions. Some key points include: operators can only be overloaded for user-defined types, not built-in types; overloaded operators retain precedence and number of operands; common uses of operator overloading include complex number arithmetic and string manipulation. The document also discusses type conversions between basic and user-defined types using constructors and casting operators.
C++ functions require prototypes that specify the return type and parameters. Function overloading allows multiple functions to have the same name but different signatures. Default arguments allow functions to be called without providing trailing arguments. Inline functions expand the function body at the call site for small functions to reduce overhead compared to regular function calls.
The document discusses various aspects of template type deduction in C++ including:
1. How the type T and the type of the parameter ParamType are deduced based on whether ParamType is a pointer/reference, universal reference, or neither.
2. How array arguments are handled differently when passed by value versus by reference in templates.
3. How function arguments are treated, with function types decaying to function pointers.
4. The differences between auto type deduction and template type deduction.
5. How decltype can be used to deduce types from expressions while preserving reference-ness.
The document discusses toolchains and cross toolchains. It defines a toolchain as a collection of tools including a C compiler, C libraries, and binary utilities. A cross toolchain is a toolchain configured to compile code for a platform other than the one on which the toolchain is running. The document outlines steps for building a cross toolchain, including obtaining kernel headers, building binary utilities, compilers, and libraries. It also discusses automated build tools like Crosstool and testing the generated cross toolchain.
The document is a tutorial on C++11 concurrency features such as asynchronous tasks, threads, promises, mutexes, and condition variables. It covers topics like spawning asynchronous tasks using std::async and std::thread, returning values from asynchronous tasks, passing parameters, handling exceptions, manually setting futures using std::promise and std::packaged_task, waiting for multiple futures, and using mutexes and lock guard templates for synchronization. Code examples are provided to illustrate the various concurrency features.
The document discusses Ethernet device drivers in Linux. It describes the driver architecture, Ethernet packet format, driver development process, and important data structures like net_device and sk_buff. It provides examples of initializing a driver, probing hardware, uploading/downloading data using callbacks, interrupt handling, and buffer management. The key steps are registering the driver, allocating network devices, setting callbacks, and using sk_buff objects to transfer packets between layers.
The document discusses various string handling, mathematical, and random number generation functions available in C++ library. It provides examples of functions like strlen(), strcpy(), strcmp(), sqrt(), pow(), randomize(), random(). It also provides programs to demonstrate the use of these functions for tasks like checking palindromes, searching strings, toggling case, generating random numbers in a given range.
Utah Code Camp, Spring 2016. http://utahcodecamp.com In this presentation I describe modern C++. Modern C++ assumes features introduced in the C++11/14 standard. An overview of the new features is presented and some idioms for mdoern C++ based on those features are presented.
The document discusses different types of loops in C programming: for loops, while loops, and do-while loops. For loops allow initialization of a variable, specify a condition, and how to increment the variable. While loops repeatedly execute code as long as a condition is true. Do-while loops are similar but check the condition at the bottom of the loop, so the code executes at least once. Examples of each loop type are provided.
The document discusses developing network device drivers for embedded Linux. It covers key topics like socket buffers, network devices, communicating with network protocols and PHYs, buffer management, and differences between Ethernet and WiFi drivers. The outline lists these topics and others like throughput and considerations. Prerequisites include C skills, Linux knowledge, and an understanding of networking and embedded driver development.
Exceptions are runtime errors that a program may encounter. There are two types: synchronous from faults in input data, and asynchronous from external events. Exception handling uses try, throw, and catch keywords. Code that may cause exceptions is placed in a try block. When an exception occurs it is thrown, and the catch block handles it to prevent program termination. Multiple catch blocks can handle different exception types, and a catch-all block uses ellipses to catch any exception.
C has been the most commonly used language. This slideshare is all about the introduction to Advanced C. You will learn the fundamentals and the problem solving skills. You will also get an idea on building algorithms and the conditions regarding it. There are also slides which will give knowledge about operators and their types. As a whole you will gain knowledge on three important fundamentals of C.
- C is a commonly used language for embedded systems that is portable, produces efficient code, and uses a fairly concise syntax.
- It was developed in the late 1960s and early 1970s and was influenced by the B programming language.
- C uses basic data types, functions, expressions, statements, and other constructs to provide powerful yet flexible programming capabilities while using relatively little memory.
The document discusses inline functions in C++. Inline functions allow code from a function to be pasted directly into the call site rather than executing a function call. This avoids overhead from calling and returning from functions. Good candidates for inline are small, simple functions called frequently. The document provides an example of a function defined with the inline keyword and the optimizations a compiler may perform after inlining. It also compares inline functions to macros and discusses where inline functions are best used.
C++11 introduced several new features for functions and lambdas including:
1. Lambda expressions that allow the definition of anonymous inline functions.
2. The std::function wrapper that allows functions and lambdas to be used interchangeably.
3. std::bind that binds arguments to function parameters for creating function objects.
These features improved support for functional programming patterns in C++.
GDB can debug programs by running them under its control. It allows inspecting and modifying program state through breakpoints, watchpoints, and examining variables and memory. GDB supports debugging optimized code, multi-threaded programs, and performing tasks like stepping, continuing, and backtracing through the call stack. It can also automate debugging through commands, scripts, and breakpoint actions.
Here is a C program to produce a spiral array as described in the task:
#include <stdio.h>
int main() {
int n = 5;
int arr[n][n];
int num = 1;
int rowBegin = 0;
int rowEnd = n-1;
int colBegin = 0;
int colEnd = n-1;
while(rowBegin <= rowEnd && colBegin <= colEnd) {
// Top row
for(int i=colBegin; i<=colEnd; i++) {
arr[rowBegin][i] = num++;
}
rowBegin++;
// Right column
for(int i=rowBegin;
C++17 introduced updates to both the C++ language and standard library. For the language, there were around 45 modest proposals that mostly solved frustrations from prior standards. Significant updates to the library included new vocabulary types like std::optional and std::string_view. C++17 also added features like structured bindings, if constexpr, and lambda improvements like constexpr lambdas and capture of *this. The filesystem library was standardized to provide OS-abstraction for file/directory operations.
10 Of The Best Books About TCP/IP And Networking
1.Internet Core Protocols: The Definitive Guide: Help for Network Administrators
2.Effective TCP/IP Programming: 44 Tips to Improve Your Network Programs
3.TCP/IP Explained
4.High-Speed Networks TCP/IP and ATM Design Principles
5.TCP/IP: Architecture, Protocols, and Implementation with IPv6 and IP
6.SNMP, SNMPv2, SNMPv3, and RMON 1 and 2
7.SNMP: A Guide to Network Management
8.TCP/IP Network Administration
9.Teach Yourself Tcp/Ip in 14 Days
10.UNIX Network Programming
The document provides an overview of Bjarne Stroustrup's views on the C++ programming language. Some key points:
1) C++ aims to provide performance, predictability, teachability, and readability while supporting systems programming, embedded systems, large systems, and both experts and novices.
2) C++ offers features like mapping to hardware, classes, inheritance, templates, and generic programming while not requiring a garbage collector for resource management.
3) Resource management in C++ relies on resource handles, RAII, and move semantics rather than a garbage collector. Templates and generic programming are designed to be as efficient and well-specified as traditional code.
This document provides an overview of new features introduced in C++11, including automatic variables, decltype, rvalue references, lambda functions, variadic templates, and the concurrency library. It discusses each feature in detail and provides examples. It also outlines compiler support for C++11 in different versions of Visual Studio and references additional learning resources on C++11.
"Http protocol and other stuff" by Bipin UpadhyayBipin Upadhyay
A holistic view of how the web works, with an overview of the HTTP protocol.
Presented by me at null security group (http://null.co.in), Mumbai chapter meet on Aug' 27th.
The HTTP protocol is an application-level protocol used for distributed, collaborative, hypermedia information systems. It operates as a request-response protocol between clients and servers, with clients making requests using methods like GET and POST and receiving responses with status codes. Requests and responses are composed of text-based headers and messages to communicate metadata and content. Caching and cookies can be used to improve performance and maintain state in this otherwise stateless protocol.
The document discusses the history and development of the internet over the past 50 years, from its origins as a network created by the United States Department of Defense to support research and education, to its subsequent commercialization and global adoption driven by the creation of the World Wide Web in the early 1990s. It grew exponentially from being used primarily by academic and military institutions to becoming integrated into the daily lives of billions of people worldwide for communication, education, commerce, and entertainment.
C++11 introduced many new features including type deduction with auto, uniform initialization syntax, rvalue references and move semantics, improved enums, lambda expressions, and smart pointers. Type deduction with auto lets the compiler deduce the type of a variable based on its initializer. Uniform initialization uses curly braces {} and allows narrowing conversions only if explicitly cast. Rvalue references and move semantics allow moving an object to avoid expensive copies by leaving the source object in a valid but unspecified state.
Networking - TCP/IP stack introduction and IPv6Rodolfo Kohn
The document discusses IPv6 and Mobile IPv6 fundamentals, new services, and applications. It begins with an introduction to TCP/IP and the Internet and then covers the OSI and TCP/IP reference models. It describes the physical, data link, network, transport, and application layers. It focuses on IPv6 features like addressing, autoconfiguration, and mobility support through Mobile IPv6. It also discusses new applications and challenges with the transition from IPv4 to IPv6.
Database connectivity to sql server asp.netHemant Sankhla
This ppt will help those who are beginner in sql server, asp.net and C# and want to learn database connectivity. So i provide them the simpler code on this universe for their database enabled web or desktop application.
C++11 Idioms @ Silicon Valley Code Camp 2012 Sumant Tambe
C++11 feels like a new language. Compared to its previous standards, C++11 packs more language features and libraries designed to make C++ programs easier to understand and faster. As the community is building up experience with the new features, new stylistic ways of using them are emerging. These styles (a.k.a. idioms) give the new language its unique flavor. This talk will present emerging idioms of using rvalue references -- a marquee feature of C++11 as many renowned experts call it. You will see how C++11 opens new possibilities to design class interfaces. Finally, you will learn some advanced use-cases of rvalue references which will likely make you feel something amiss in this flagship feature of C++11.
The document discusses principles of writing good C++ code. It begins by criticizing existing code examples as "ghastly style" that are difficult to understand and maintain. It advocates for a type-rich interface style with compact data structures and well-structured algorithms. The document also emphasizes writing code with modularity, effective resource management, and thread safety by default. The presentation provides examples demonstrating these principles using C++11 features like auto, type aliases, and literals.
This document provides an introduction to database programming and ADO.NET. It outlines the objectives and key concepts, including the hardware and software components of a client/server database system, how tables and records are organized in a relational database, common SQL statements, and the core ADO.NET classes like the connection, command, data adapter and dataset. It also covers topics like joining data from multiple tables, concurrency handling, and how ADO.NET objects can be created either from a data source or directly using code.
The document outlines requirements for an IT 211 Data Structures midterm. It includes 3 programming problems: 1) a program to track election results and declare a winner, 2) a program to count words, sentences, and paragraphs in input text, and 3) programs to convert between binary and decimal numbers recursively. It also provides lecture requirements on defining and implementing stacks, lists, queues, and pointers in C++.
A glimpse at some of the new features for the C++ programming languages that will be introduced by the upcoming C++17 Standard.
This talk was given at the Munich C++ User Group Meetup.
HTTPS: What, Why and How (SmashingConf Freiburg, Sep 2015)Guy Podjarny
When users use our sites, they put their faith in us. They trust we will keep their information from reaching others, believe we provided the information they see, and allow us to run (web) code on their devices. Using HTTPS to secure our conversations is a key part of maintaining this trust.
If that’s not motivation enough, the web’s giants are actively promoting HTTPS, requiring it for features such as HTTP2 & ServiceWorker, using it for search engine ranking and more. To make the most of the web, you need to use HTTPS.
This deck reviews what HTTPS is, discusses why you should prioritize using it, and cover some of the easiest (and most cost effective) steps to get started using HTTPS
Slides from my "Gentle Introduction to Modern C++" presentation from January 20, 2015 at the Dublin C/C++ User Group: www.meetup.com/cppdug/events/219787667/
The code examples are located here: https://github.com/mihaitodor/Presentations/tree/master/cppdug/20.01.2015
C++11 introduced several new features to C++ that support modern programming patterns like lambdas, smart pointers, and move semantics. Lambdas allow for anonymous inline functions, which improve code readability and eliminate the need for functor classes. Smart pointers like unique_ptr and shared_ptr make memory management safer and more straightforward using features like move semantics and RAII. C++11 also aims to bring C++ more in line with modern hardware by supporting multi-threading and higher level abstractions while maintaining performance.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
The document provides an overview of the C programming language. It begins by explaining that Objective-C extends standard ANSI C with object-oriented capabilities. It then discusses why C remains important today due to its use in libraries, operating systems, and as the base for many other popular languages. The document proceeds to cover basic C concepts like variables, data types, functions, flow control, pointers, memory allocation, and I/O parameters. It emphasizes that C provides high performance with a minimal footprint while abstracting away the CPU and memory.
Object oriented programming system with C++msharshitha03s
This document provides an overview of C++ control statements, functions, and storage classes. It discusses various loops like while, for, and do-while loops. It also covers decision making statements such as if-else, if-else-if-else, switch statements, and unconditional statements like break, continue, and goto. The document then discusses functions, recursion, and inline functions. Finally, it summarizes different storage classes in C++ like auto, register, static, external, and mutable and provides examples of each.
The document provides information about C and C Sharp programming languages. It discusses the history, features, data types, loops, conditional statements, functions, arrays, pointers, object-oriented concepts like inheritance, encapsulation, polymorphism in both the languages. It also highlights some advantages of C Sharp over C like automatic memory management, no need of header files etc.
This document provides an introduction to the C programming language. It discusses fundamental C elements like data types, variables, constants, operators, and input/output functions. It explains how a basic C program is structured and compiled. Examples are provided to demonstrate simple C statements, arithmetic expressions, and how to write and run a first program that prints text. The key topics covered include basic syntax, program structure, data types, identifiers, operators, and input/output functions like printf() and scanf().
The document discusses various topics related to C language including:
- Benefits and features of C like low-level operations, structured programming, and modular programming
- Data types in C like fundamental types (char, int, float), derived types, and defining variables
- Structure of C functions including single-level and multiple-level functions
- Input-output functions in C like character-based (getc, putc), string-based (gets, puts)
The document discusses C++0x standard library extensions (TR1) and advanced C++ techniques. It provides an overview of new features in C++0x related to the core language like type inference, lambda functions, and rvalue references. It also discusses changes to the C++ standard library like tuples, hash tables, smart pointers, and other containers. The document is intended as course material covering these new C++0x features.
Functions And Header Files In C++ | Bjarne stroustrupSyedHaroonShah4
This document discusses functions and header/source files in C++. It covers declarations, definitions, and the differences between them. Declarations introduce names and specify types, while definitions also fully specify the entity. Declarations allow interfaces to be specified. Headers contain declarations to share interfaces between parts of a program. Functions are described as units of operation that can take parameters and return values. The document also discusses scopes, namespaces, and storage classes like static.
The document provides an overview of the C++ programming language. It discusses that C++ was created by Bjarne Stroustrup to provide Simula's facilities for program organization together with C's efficiency and flexibility for systems programming. The document outlines key C++ features like classes, templates, operator overloading, and exceptions. It also covers topics like class definitions, constructors, destructors, streams, and compiling/linking C++ programs.
The document provides suggestions for using various new C++11 language features in ATS coding, focusing on features that are most useful. It discusses nullptr, auto, range-based for loops, delegating constructors, prohibiting/defaulting methods, member initialization, override, explicit conversion operators, std::unique_ptr, lambdas, std::function, constexpr, and provides code examples for many of these features. The overall aim is to take advantage of new language features to improve ATS code without overusing them in a way that makes the code harder to understand.
C++ is an object-oriented programming language that was created as an extension of C programming language. It was created by Bjarne Stroustrup in 1979 at Bell Labs. Some key differences between C and C++ include C++ supporting object-oriented programming concepts like classes, inheritance and polymorphism, while C is a procedural language. Pointers and references are commonly used in C++ to pass arguments to functions by reference rather than by value. Arrays and functions are also important elements of C++ programs.
C++ is an object-oriented programming language that was created as an extension of C by Bjarne Stroustrup in 1979 at Bell Labs. It supports concepts like inheritance, polymorphism, and encapsulation. C++ is a systems programming language that is commonly used to develop applications that require high performance or require low-level access to hardware. Some key features of C++ include object-oriented programming, functions, arrays, pointers, strings, file handling, and inheritance. C++ allows programmers to write code that is very close to the underlying hardware and has performance advantages over other languages.
The document provides an overview of the C++ programming language. It discusses the history and development of C++, with key points being that C++ was created by Bjarne Stroustrup in 1983 as an extension of C to support object-oriented programming. It then covers some of the main differences between C and C++, uses of C++, advantages and disadvantages, standard libraries, basic C++ structures like data types, variables, operators, functions, arrays, and pointers.
This document provides an overview of the C++ programming language. It discusses key C++ concepts like classes, objects, functions, and data types. Some key points:
- C++ is an object-oriented language that is an extension of C with additional features like classes and inheritance.
- Classes allow programmers to combine data and functions to model real-world entities. Objects are instances of classes.
- The document defines common C++ terms like keywords, identifiers, constants, and operators. It also provides examples of basic programs.
- Functions are described as modular and reusable blocks of code. Parameter passing techniques like pass-by-value and pass-by-reference are covered.
- Other concepts covered include
This document provides information about the C# programming language. It discusses that C# is an object-oriented language that can be used to build a variety of applications like Windows and web. Visual C# .NET is Microsoft's integrated development environment (IDE) for building C# applications and is part of the Visual Studio suite. The document also covers C# language fundamentals like variables, data types, operators, and conditional statements.
The document provides details of programs to be implemented in C++ and Java as part of an Object Oriented Programming lab. The C++ programs include implementations of inline function overloading, complex numbers using operator overloading, friend functions, string concatenation using dynamic memory allocation, type conversion using complex numbers, managing bank accounts using inheritance, and a stack class with exception handling. The Java programs include writing simple programs, palindrome checking using strings, interfaces, inheritance, exception handling, and multithreaded programs.
Implémentation efficace et durable de processus métiers complexesGeeks Anonymes
La transposition de processus métiers complexes en programmes informatiques est parfois difficile pour des raisons techniques et/ou communicationnelles. Le faire efficacement et sous une forme flexible l'est encore plus. Pousse-Café, un framework Java se basant sur le Domain-Driven Design (DDD), rend la tâche plus abordable. https://www.pousse-cafe-framework.org/
Par Gérard Dethier, aux Geeks Anonymes du 15 janvier 2021
Vidéo : https://youtu.be/DE0QpTIz1cQ
Managing Open Source Licenses (Geeks Anonymes)Geeks Anonymes
This document discusses open source software licenses and managing open source code. It provides an overview of common open source licenses like GPL, MIT, and BSD licenses. It also discusses risks of license incompatibility and how to detect open source code dependencies. The document recommends that developers choose licenses carefully, document code properly, and that companies establish open source policies.
Conférence des Geeks Anonymes sur " Reprendre le contrôle de ses données ", par Gérard Dethier, le 26 octobre 2020.
Vidéo : https://youtu.be/RUbZ9RbI7TA
Conférence des Geeks Anonymes sur " le langage Go ", par Thomas Hayen le 23 septembre 2020.
Cette conférence est disponible en vidéo sur Youtube : https://youtu.be/AlGGneVGTJk
This document provides an overview of Kubernetes including: its architecture with key components like kubelet, kube-proxy, controller manager, scheduler, and etcd; how it manages deployments with rolling updates and rollbacks; jobs; services; ingress; volumes; configmaps and secrets; namespaces; cronjobs and daemonsets; readiness and liveness probes; statefulsets; network policies; RBAC and security; and a brief history of Kubernetes. It also includes contact information for Philippe Collignon who provides additional context on his experience with Kubernetes.
Rust is a systems programming language that offers performance comparable to C and C++ with memory safety and thread safety. It uses a borrow checker to enforce rules around ownership, borrowing, and lifetimes that prevent common bugs like use of dangling pointers and data races. Rust also supports features like generics, pattern matching, and idioms that improve productivity without sacrificing performance.
This document discusses best practices for testing code. It recommends writing unit, integration, functional, generated, and performance tests. Unit tests should be isolated, reproducible, fast, simple, and automated. Integration tests check interactions between components. Functional tests simulate user behaviors. Generated tests use random inputs to try breaking code. Performance tests measure timing and load capacity. The document provides examples of tools and techniques for writing different types of tests in Python.
Become Rick and famous, thanks to Open SourceGeeks Anonymes
This document discusses how to become rich and famous through open source software by attracting users and developers, and outlines various business models for monetizing open source projects including services, dual licensing, and creating added value products. It notes that choosing open source allows for social impact, helps customers avoid lock-in, and helps attract talent from the open source community.
This document provides an introduction to natural language processing (NLP) and discusses various NLP techniques. It begins by introducing the author and their background in NLP. It then defines NLP and common text data used. The document outlines a typical NLP pipeline that involves pre-processing text, feature engineering, and both low-level and high-level NLP tasks. Part-of-speech tagging and sentiment analysis are discussed as examples. Deep learning techniques for NLP are also introduced, including word embeddings and recurrent neural networks.
1. The document discusses modern features of SQL such as window functions, common table expressions, grouping sets, rollup and cube.
2. It provides examples and explanations of these features and how they can be used to analyze and query data in flexible ways.
3. Compatibility of these features across major database systems such as PostgreSQL, SQL Server, and Oracle is also discussed.
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfTrackobit
What do fleet managers do? What are their duties, responsibilities, and challenges? And what makes a fleet manager effective and successful? This blog answers all these questions.
IN Dubai [WHATSAPP:Only (+971588192166**)] Abortion Pills For Sale In Dubai** UAE** Mifepristone and Misoprostol Tablets Available In Dubai** UAE
CONTACT DR. SINDY Whatsapp +971588192166* We Have Abortion Pills / Cytotec Tablets /Mifegest Kit Available in Dubai** Sharjah** Abudhabi** Ajman** Alain** Fujairah** Ras Al Khaimah** Umm Al Quwain** UAE** Buy cytotec in Dubai +971588192166* '''Abortion Pills near me DUBAI | ABU DHABI|UAE. Price of Misoprostol** Cytotec” +971588192166* ' Dr.SINDY ''BUY ABORTION PILLS MIFEGEST KIT** MISOPROSTOL** CYTOTEC PILLS IN DUBAI** ABU DHABI**UAE'' Contact me now via What's App… abortion pills in dubai Mtp-Kit Prices
abortion pills available in dubai/abortion pills for sale in dubai/abortion pills in uae/cytotec dubai/abortion pills in abu dhabi/abortion pills available in abu dhabi/abortion tablets in uae
… abortion Pills Cytotec also available Oman Qatar Doha Saudi Arabia Bahrain Above all** Cytotec Abortion Pills are Available In Dubai / UAE** you will be very happy to do abortion in Dubai we are providing cytotec 200mg abortion pills in Dubai** UAE. Medication abortion offers an alternative to Surgical Abortion for women in the early weeks of pregnancy. We only offer abortion pills from 1 week-6 Months. We then advise you to use surgery if it's beyond 6 months. Our Abu Dhabi** Ajman** Al Ain** Dubai** Fujairah** Ras Al Khaimah (RAK)** Sharjah** Umm Al Quwain (UAQ) United Arab Emirates Abortion Clinic provides the safest and most advanced techniques for providing non-surgical** medical and surgical abortion methods for early through late second trimester** including the Abortion By Pill Procedure (RU 486** Mifeprex** Mifepristone** early options French Abortion Pill)** Tamoxifen** Methotrexate and Cytotec (Misoprostol). The Abu Dhabi** United Arab Emirates Abortion Clinic performs Same Day Abortion Procedure using medications that are taken on the first day of the office visit and will cause the abortion to occur generally within 4 to 6 hours (as early as 30 minutes) for patients who are 3 to 12 weeks pregnant. When Mifepristone and Misoprostol are used** 50% of patients complete in 4 to 6 hours; 75% to 80% in 12 hours; and 90% in 24 hours. We use a regimen that allows for completion without the need for surgery 99% of the time. All advanced second trimester and late term pregnancies at our Tampa clinic (17 to 24 weeks or greater) can be completed within 24 hours or less 99% of the time without the need for surgery. The procedure is completed with minimal to no complications. Our Women's Health Center located in Abu Dhabi** United Arab Emirates** uses the latest medications for medical abortions (RU-486** Mifeprex** Mifegyne** Mifepristone** early options French abortion pill)** Methotrexate and Cytotec (Misoprostol). The safety standards of our Abu Dhabi** United Arab Emirates Abortion Doctors remain unparalleled. They consistently maintain the lowest complication rates throughout the nation. Our
Overview of ERP - Mechlin Technologies.pptxMitchell Marsh
This PowerPoint presentation provides a comprehensive overview of Enterprise Resource Planning (ERP) systems. It covers the fundamental concepts, benefits, and key functionalities of ERP software, illustrating how it integrates various business processes into a unified system. From finance and HR to supply chain and customer relationship management, ERP facilitates efficient data management and decision-making across organizations. Whether you're new to ERP or looking to deepen your understanding, this presentation offers valuable insights into leveraging ERP for business success.
Attendance Tracking From Paper To DigitalTask Tracker
If you are having trouble deciding which time tracker tool is best for you, try "Task Tracker" app. It has numerous features, including the ability to check daily attendance sheet, and other that make team management easier.
Break data silos with real-time connectivity using Confluent Cloud Connectorsconfluent
Connectors integrate Apache Kafka® with external data systems, enabling you to move away from a brittle spaghetti architecture to one that is more streamlined, secure, and future-proof. However, if your team still spends multiple dev cycles building and managing connectors using just open source Kafka Connect, it’s time to consider a faster and cost-effective alternative.
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...Hironori Washizaki
Hironori Washizaki, "Charting a Course for Equity: Strategies for Overcoming Challenges and Promoting Inclusion in the Metaverse", IEEE COMPSAC 2024 D&I Panel, 2024.
An MVP (Minimum Viable Product) mobile application is a streamlined version of a mobile app that includes only the core features necessary to address the primary needs of its users. The purpose of an MVP is to validate the app concept with minimal resources, gather user feedback, and identify any areas for improvement before investing in a full-scale development. This approach allows businesses to quickly launch their app, test its market viability, and make data-driven decisions for future enhancements, ensuring a higher likelihood of success and user satisfaction.
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.bhatinidhi2001
CViewSurvey is a SaaS-based Web & Mobile application that provides digital transformation to traditional paper surveys and feedback for customer & employee experience, field & market research that helps you evaluate your customer's as well as employee's loyalty.
With our unique C.A.A.G. Collect, Analysis, Act & Grow approach; business & industry’s can create customized surveys on web, publish on app to collect unlimited response & review AI backed real-time data analytics on mobile & tablets anytime, anywhere. Data collected when offline is securely stored in the device, which syncs to the cloud server when connected to any network.
React and Next.js are complementary tools in web development. React, a JavaScript library, specializes in building user interfaces with its component-based architecture and efficient state management. Next.js extends React by providing server-side rendering, routing, and other utilities, making it ideal for building SEO-friendly, high-performance web applications.
NBFC Software: Optimize Your Non-Banking Financial CompanyNBFC Softwares
NBFC Software: Optimize Your Non-Banking Financial Company
Enhance Your Financial Services with Comprehensive NBFC Software
NBFC software provides a complete solution for non-banking financial companies, streamlining banking and accounting functions to reduce operational costs. Our software is designed to meet the diverse needs of NBFCs, including investment banks, insurance companies, and hedge funds.
Key Features of NBFC Software:
Centralized Database: Facilitates inter-branch collaboration and smooth operations with a unified platform.
Automation: Simplifies loan lifecycle management and account maintenance, ensuring efficient delivery of financial services.
Customization: Highly customizable to fit specific business needs, offering flexibility in managing various loan types such as home loans, mortgage loans, personal loans, and more.
Security: Ensures safe and secure handling of financial transactions and sensitive data.
User-Friendly Interface: Designed to be intuitive and easy to use, reducing the learning curve for employees.
Cost-Effective: Reduces the need for additional manpower by automating tasks, making it a budget-friendly solution. Benefits of NBFC Software:
Go Paperless: Transition to a fully digital operation, eliminating offline work.
Transparency: Enables managers and executives to monitor various points of the banking process easily.
Defaulter Tracking: Helps track loan defaulters, maintaining a healthy loan management system.
Increased Accessibility: Cutting-edge technology increases the accessibility and usability of NBFC operations. Request a Demo Now!
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Modern c++ (C++ 11/14)
1. Usability enhancements Type deduction Move semantics Lambda expressions
Modern C++ (C++11/14)
Geeks Anonymes
Damien Gerard
October 19th, 2016
2. Usability enhancements Type deduction Move semantics Lambda expressions
Introduction
“C++11 feels like a new language.” Bjarne Stroustrup (inventor of C++)
3. Usability enhancements Type deduction Move semantics Lambda expressions
Labels
11 since C++11
14 since C++14
17 since C++17
R that ain’t for kids
4. Usability enhancements Type deduction Move semantics Lambda expressions
Range-based for loop
for statement syntax extended to allow for easy iteration over a range of
elements:
int myArray[5] = {1, 2, 3, 4, 5};
for(int x : myArray) {
std::cout << x << std::endl;
}
for(int& x : myArray) {
x *= 2; // double value and save
}
for(auto& x : myArray) { // auto = int
x *= 2;
}
11
5. Usability enhancements Type deduction Move semantics Lambda expressions
auto
Constant iterator over a vector:
std::vector<int> vec(4,100); // four ints with value 100
for(std::vector<int>::const_iterator it = vec.cbegin();
it != vec.cend(); ++it)
{
std::cout << *it << std::endl;
}
auto for type deduction:
std::vector<int> vec(4,100); // four ints with value 100
for(auto it = vec.cbegin(); it != vec.cend(); ++it) {
std::cout << *it << std::endl;
}
11
6. Usability enhancements Type deduction Move semantics Lambda expressions
Null pointer literal
Constant 0 had the double role of constant integer and null pointer
constant.
void f(int*);
void f(int);
f(NULL); // calls f(int) or error: ambiguous
If NULL defined as 0, f(NULL) calls f(int). Most programmers would
expect f(int*) because NULL means a null pointer in their mind.
7. Usability enhancements Type deduction Move semantics Lambda expressions
Null pointer literal
nullptr is a pointer literal of type nullptr_t, which is implicitly
convertible and comparable to any pointer type. It is not implicitly
convertible or comparable to integral types, except for bool.
char* pc = nullptr; // compiles
int* pi = nullptr; // compiles
bool b = nullptr; // compiles, b is false
int i = nullptr; // error
f(nullptr); // calls f(int*), not f(int)
f(nullptr_t) will actually call f(int*) using implicit conversion.
11
8. Usability enhancements Type deduction Move semantics Lambda expressions
Initializer lists
C++03 inherited the initializer-list feature from C.
struct Widget {
float first;
int second;
};
Widget w1 = {0.43f, 10}; // first=0.43f and second=10
Widget w2[] = {{13.4f, 3}, {43.2f, 29}};
Useful albeit limited to Plain Old Data (POD) structs and classes.
9. Usability enhancements Type deduction Move semantics Lambda expressions
Uniform initialization
Initializer-lists for all classes, including standard containers.
std::vector<std::string> v = { "Hello", "world" };
std::vector<std::string> v({ "Hello", "world" });
std::vector<std::string> v{ "Hello", "world" };
int val = 5.2; // automatic narrowing
int val{5.2}; // error or warning: type ’double’
// cannot be narrowed to ’int’ in initializer list
// insert an explicit static cast static_cast<int>( )
Widget getWidget() {
return {0.43f, 10}; // no need for explicit type
}
11
10. Usability enhancements Type deduction Move semantics Lambda expressions
Most vexing parse
struct Widget {
Widget();
};
struct WidgetKeeper {
WidgetKeeper(Widget w);
};
WidgetKeeper wKeeper(Widget()); // most vexing parse
Ambiguous call:
1 new instance of Widget, sent to constructor of WidgetKeeper;
2 function declaration: name“wKeeper”, return type WidgetKeeper,
single (unnamed) parameter which is a function returning type
Widget.
11. Usability enhancements Type deduction Move semantics Lambda expressions
Most vexing parse
Most developers expect the first, but the C++ standard requires it to be
interpreted as the second.
Workaround in C++03 to ensure the first interpretation:
WidgetKeeper time_keeper( (Widget()) );
C++11’s uniform initialization syntax:
WidgetKeeper time_keeper{Widget{}}; 11
12. Usability enhancements Type deduction Move semantics Lambda expressions
Returning multiple values
void divide(int dividend, int divisor, int& quotient,
int& remainder)
{
quotient = dividend / divisor;
remainder = dividend % divisor;
}
Or even worse, return quotient through the returned value and
remainder as a reference variable:
int divide(int dividend, int divisor, int& remainder) {
remainder = dividend % divisor;
return dividend / divisor;
}
13. Usability enhancements Type deduction Move semantics Lambda expressions
Returning multiple values
Or, but rather heavy:
struct divideResult {
int quotient;
int remainder;
};
divideResult divide(int dividend, int divisor) {
return { dividend / divisor, dividend % divisor };
}
divideResult result = divide(10, 3);
std::cout << result.quotient << std::endl;
std::cout << result.remainder << std::endl;
11
14. Usability enhancements Type deduction Move semantics Lambda expressions
Returning multiple values
std::tuple<int,int> divide(int dividend, int divisor) {
return std::make_tuple(dividend / divisor,
dividend % divisor);
}
int quotient, remainder;
std::tie(quotient, remainder) = divide(10, 3);
C++17’s structured bindings (Clang-4.0 only, as of today):
auto [quotient, remainder] = divide(10, 3);
std::cout << quotient << std::endl;
std::cout << remainder << std::endl;
11
17
15. Usability enhancements Type deduction Move semantics Lambda expressions
std::unordered *
std::set, map, multiset, multimap associative containers are
implemented as balanced trees. The std::unordered_set,
unordered_map, unordered_multiset, unordered_multimap
alternatives are implemented as hash tables.
Including hash tables was one of the most recurring requests. It was not
adopted in C++03 due to time constraints only. Although hash tables are
less efficient than a balanced tree in the worst case (in the presence of
many collisions), they perform better in many real applications.
11
16. Usability enhancements Type deduction Move semantics Lambda expressions
emplace, emplace back
emplace and emplace_back can construct an element in-place.
auto employees = std::unordered_map<int, std::string>{};
auto e1 = std::pair<int, std::string>{1, "John Smith"};
employees.insert(e1);
employees.insert(std::make_pair(2, "Mary Jones"));
employees.emplace(3, "James Brown"); // construct in-place
for (const auto& e : employees) {
std::cout << e.first << ": " << e.second << std::endl;
}
11
17. Usability enhancements Type deduction Move semantics Lambda expressions
In-class initialization
In C++03, in-class initialization on static const members of integral or
enumeration type only.
struct Widget {
static const int a = 7; // compiles
float b = 7.2; // error: not static const integral
const int c = 7; // error: not static
static int d = 7; // error: not const
static const float e = 7.2; // error: not integral
const static int arr[] = { 1, 2, 3 };
// error: must be initialized out of line
};
18. Usability enhancements Type deduction Move semantics Lambda expressions
In-class initialization
C++11 allows some of them:
struct Widget {
static const int a = 7;
float b = 7.2;
const int c = 7;
static int d = 7; // still fails
static float e = 7.2; // still fails
constexpr static int arr[] = { 1, 2, 3 };
constexpr static std::complex<double> f = { 1, 2 };
};
A non-const static variable still has to be initialized outside the class with
int Widget::d = 7;
float Widget::e = 7.2;
11
19. Usability enhancements Type deduction Move semantics Lambda expressions
ODR-use
An object is odr-used if its address is taken, or a reference is bound to it.
If a const or constexpr static data member is odr-used, a redefinition (no
initializer permitted) at namespace scope is required.
struct Widget {
static const int n = 1;
static constexpr int m = 4;
};
const int& f(const int& r);
// call f(Widget::n) or f(Widget::m) somewhere
// redefinition at namespace scope required:
const int Widget::n, Widget::m;
C++17 alleviates this constraint for constexpr. A static data member
declared constexpr is implicitly inline and needs not be redeclared at
namespace scope.
R
11
17
20. Usability enhancements Type deduction Move semantics Lambda expressions
constexpr
Declare something that can be evaluated down to a constant:
constexpr double pi() { return std::atan(1) * 4; }
constexpr double getCircleSurface(double r) {
return pi() * r * r;
}
const double circleSurface = getCircleSurface(0.5);
or
const float oneEighty = degreesToRadians(180.0f);
Since C++14, constexpr functions may have more than one line.
11
14
21. Usability enhancements Type deduction Move semantics Lambda expressions
Call other constructors
In C++03, other constructors could not be called. Workaround: call a
common member function
class Widget {
int number_;
void construct(int number) { number_ = number; }
public:
Widget(int number) { construct(number); }
Widget() { construct(42); }
};
22. Usability enhancements Type deduction Move semantics Lambda expressions
Call other constructors
Wrong workaround:
class Widget {
int number_;
public:
Widget(int number) : number_(number) { }
Widget() {
Widget(42);
// this->number_ = 0 or something undefined
}
};
What is wanted but does not compile:
Widget() : Widget(42) { }
23. Usability enhancements Type deduction Move semantics Lambda expressions
Call other constructors
In C++11 other peer constructors may be called (“delegation”).
class Widget {
int number_;
public:
Widget(int number) : number_(number) { }
Widget() : Widget(42) { }
};
An object is constructed once any constructor finishes execution. Since
multiple constructors are allowed to execute, each delegating constructor
will be executing on a fully constructed object of its own type.
11
24. Usability enhancements Type deduction Move semantics Lambda expressions
Call or import base class constructors
Call base class constructor:
struct Base {
Base(int number);
};
struct Derived : Base {
Derived(int number) : Base(number) { }
};
Import all base class constructors:
struct Derived : Base {
using Base::Base
};
// can call Derived(42);
11
25. Usability enhancements Type deduction Move semantics Lambda expressions
Override a base class method
struct Animal {
char* say() const { return "??"; }
};
struct Cow : Animal {
char* say() const { return "moo"; }
};
struct Pig : Animal {
char* say() const { return "oink"; }
};
std::vector<Animal*> animals{new Cow, new Pig};
for(const Animal* a : animals) {
std::cout << a->say() << std::endl;
}
Prints“??” for both the cow and the pig.
26. Usability enhancements Type deduction Move semantics Lambda expressions
Dynamic polymorphism
struct Animal {
virtual char* say() const { return "??"; }
};
struct Cow : Animal {
virtual char* say() const { return "moo"; }
};
struct Pig : Animal {
virtual char* say() const { return "oink"; }
};
Prints“moo”and“oink”. What if const is forgotten in the Pig’s say()? It
will compile and print“moo”and“??”.
27. Usability enhancements Type deduction Move semantics Lambda expressions
Typo in derived class
The following code compiles but contains no virtual function overrides.
struct Base {
void f1() const;
virtual void f2() const;
virtual void f3(int x);
}
struct Derived : Base {
void f1() const;
virtual void f2();
virtual void f3(unsigned int x);
}
28. Usability enhancements Type deduction Move semantics Lambda expressions
overrides
Make explicit that a derived class is expected to override a base class:
struct Derived : Base {
void f1() const override;
virtual void f2() override;
virtual void f3(unsigned int x) override;
}
The compiler will complain about all the overriding-related issues.
11
29. Usability enhancements Type deduction Move semantics Lambda expressions
final
Prevent overriding:
struct Base {
virtual void f() final;
};
struct Derived : Base {
virtual void f(); // error: ’f’ overrides a ’final’ function
};
Prevent derivation:
struct Base final { };
struct Derived : Base { }; // error: ’Base’ is marked ’final’
This could be achieved in C++03 with private virtual inheritance.
11
31. Usability enhancements Type deduction Move semantics Lambda expressions
Unrestricted unions
In C++03, unions cannot contain any objects that define a
non-trivial constructor or destructor. C++11 lifts some restrictions.
struct Widget {
int x_;
Widget() {}
Widget(int x) : x_(x) {}
};
union U {
double f;
Widget w; // illegal in C++03, legal in C++11
};
U u; // error: call to implicitely deleted default constructor o
// note: default constructor of ’U’ is implicitely deleted
// because field ’w’ has a non-trivial default constructor
11 R
32. Usability enhancements Type deduction Move semantics Lambda expressions
Unrestricted unions
A constructor for the union must be manually defined:
union U {
double f;
Widget w;
U(int x) : w(x) { }
};
U u(3);
11 R
33. Usability enhancements Type deduction Move semantics Lambda expressions
Strongly typed enumerations
C++03 enumerations are not type-safe. It allows the comparison between
two enum values of different enumeration types. Type-safe enumeration:
enum class Enum1 {
Val1 = 100,
Val2 // = 101
};
Override the default underlying type:
enum class Enum2 : unsigned long {Val1, Val2};
Other examples:
enum Enum3; // Underlying type cannot be determined (C++03/11)
enum class Enum4; // Underlying type is int (C++11)
11
34. Usability enhancements Type deduction Move semantics Lambda expressions
Template type deduction for classes
Template class:
template<typename T> // "typename" and "class" are synonymous
class Stack {
std::vector<T> elems_;
public:
void push(const T& elem) { elems_.push_back(elem); }
T top() const { return elems_.back(); }
void pop() { elems_.pop_back(); }
};
Stack<double> myStack; // T = double
Stack<int*> myStack; // T = int*
One Stack code for double and another Stack code for int*.
35. Usability enhancements Type deduction Move semantics Lambda expressions
Template type deduction for functions
template <typename T>
inline T max(T a, T b) {
return a > b ? a : b;
}
std::cout << max(3.0, 7.2) << std::endl; // T = double
std::cout << max("hello", "world") << std::endl;
struct Widget {
int x_;
Widget(int x) : x_(x) { }
};
Widget w1(3), w2(4);
std::cout << max(w1, w2) << std::endl;
// error: invalid operands to binary expression
36. Usability enhancements Type deduction Move semantics Lambda expressions
Template partial specialization for loop unrolling
The template may also be a value instead of a class, allowing e.g. for
compile-time loop unrolling, with partial specialization:
template <unsigned int N>
int factorial() {
return N * factorial<N - 1>();
}
template <>
int factorial<0>() {
return 1;
}
std::cout << factorial<4>() << std::endl; // yields 24
Since C++11, the same can be performed with constexpr.
R
11
37. Usability enhancements Type deduction Move semantics Lambda expressions
auto for variable type deduction
std::vector<int> vec{10, 11, 12, 13};
for(auto it = vec.cbegin(); it != vec.cend(); ++it) {
std::cout << *it << std::endl;
}
11
38. Usability enhancements Type deduction Move semantics Lambda expressions
decltype for return type deduction
template<typename T, typename U>
SomeType mul(T x, U y) {
return x*y;
}
The return type is“the type of x*y”. How can we write that?
template<typename T, typename U>
decltype(x*y) mul(T x, U y) {
return x*y;
}
It does not compile because x and y are not in scope. We can use a
trailing return type.
11
39. Usability enhancements Type deduction Move semantics Lambda expressions
decltype for return type deduction
Trailing return type:
template<typename T, typename U>
auto mul(T x, U y) -> decltype(x*y) {
return x*y;
}
When decltype is read, x and y are now known to the compiler. auto is
only meant to tell the compiler that it will find the return type after ->.
auto does not deduce anything.
11
40. Usability enhancements Type deduction Move semantics Lambda expressions
Generalized return type deduction
Since C++14, auto can deduce the return type of functions:
auto floor(double x) { return static_cast<int>(x); }
Multiple returns are allowed, but the type must be the same:
auto f() {
while(something()) {
if(expr) {
return foo() * 42;
}
}
return bar.baz();
}
14
41. Usability enhancements Type deduction Move semantics Lambda expressions
Generalized return type deduction
The return type deduction also works for recursive functions, provided the
non-recursive return statement is before the recursive call.
auto f() { return f(); } // error: return type of f is unknown
auto sum(int i) {
if (i == 1)
return i; // return type deduced to int
else
return sum(i-1)+i; // ok to call it now
}
14
42. Usability enhancements Type deduction Move semantics Lambda expressions
decltype(auto)
auto always deduces a non-reference type (int, double. . . ). auto&
always deduces a reference type (int&, double&. . . ). But auto cannot
conditionnaly see if the return type is a reference.
decltype can, but requires to write an expression in its parentheses.
We can use the best of both worlds with decltype(auto) which can
deduce if the type is a reference.
template<typename T, typename U>
decltype(auto) mul(T x, U y) {
return x*y;
}
14
45. Usability enhancements Type deduction Move semantics Lambda expressions
Copy-and-swap idiom
Issues:
1 code duplication;
2 if(this != &other) mandatory but should not occur;
3 if new[] fails, *this will have been modified (no strong exception
guarantee).
47. Usability enhancements Type deduction Move semantics Lambda expressions
Copy Elisions, Returned Value Optimization
Distinguish parameter and argument:
other is the parameter of the function;
the array returned by getArray(4) is the argument, from which the
parameter other is instanciated.
If the argument is a temporary object which will be destroyed, why make a
copy for other? The argument should become other, thereby avoiding
copy.
Most C++03 compilers could grasp this optimization opportunity
whenever possible and elude the copy.
Guideline: Do not copy the function arguments. Instead, pass them by
value and let the compiler manage the copying.
48. Usability enhancements Type deduction Move semantics Lambda expressions
Lvalue – Rvalue
C++11 formalized everything:
a temporary object, eligible for copy elision, is an rvalue;
otherwise it is an lvalue.
References:
an integer lvalue-reference is denoted int&;
an integer rvalue-reference is denoted int&&.
11
49. Usability enhancements Type deduction Move semantics Lambda expressions
Move constructor and move assignment operator
There are two new special member functions.
Move constructor:
Array(Array&& other) : Array() {
swap( *this, other );
}
Move assignment operator:
Array& operator=(Array&& other) {
swap( *this, other );
return *this;
}
11
50. Usability enhancements Type deduction Move semantics Lambda expressions
Specialize code for lvalue or rvalue
void f(int& param) {
std::cout << "lvalue" << std::endl;
}
void f(int&& param) {
std::cout << "rvalue" << std::endl;
}
int a;
f(a); // calls void f(int&)
f(std::move(a)); // calls void f(int&&)
If you can take a variable’s address, it usually is an lvalue. Otherwise it is
usually an rvalue.
11
51. Usability enhancements Type deduction Move semantics Lambda expressions
std::move
std::move does not move anything. It casts its parameter as an rvalue.
struct Widget {
Array arr_;
Widget(const Array& param) : arr_(std::move(param)) { }
};
Array arr(3);
Widget w(arr);
compiles but calls the copy constructor of Array instead of the move
constructor. std::move returns a const Array&& which cannot be casted
as a non-const Array&&, but can be casted as a const Array&.
Array(const Array& other); // copy constructor
Array(Array&& other); // move constructor
11
52. Usability enhancements Type deduction Move semantics Lambda expressions
Distinguish forwarding from rvalue references
A forwarding reference is either an lvalue reference or an rvalue reference.
A forwarding reference has the same syntax as an rvalue reference, namely
“&&”.
Rvalue references examples:
void f(Widget&& param);
Widget&& w1 = Widget();
Forwarding references:
template<typename T>
void f(T&& param);
auto&& w2 = w1;
11
53. Usability enhancements Type deduction Move semantics Lambda expressions
Distinguish forwarding from rvalue references
Both forwarding references have in common the presence of type
deduction. Rvalue references do not.
template<typename T>
void f(T&& param) {
// Here we can take param’s address
// so param is always an lvalue
}
Widget w;
f(w); // param’s type is lvalue-reference Widget&
// param is lvalue
// T = Widget&
f(std::move(w)); // param’s type is rvalue-reference Widget&&
// param is lvalue
// T = Widget
11
54. Usability enhancements Type deduction Move semantics Lambda expressions
std::forward
void process(Widget& lValArg); // for lvalues
void process(Widget&& rValArg); // for rvalues
template<typename T>
void logAndProcess(T&& param) {
auto now = std::chrono::system_clock::now();
makeLogEntry("Calling ’process’", now);
process(param); // always calls process(Widget&)
}
Widget w;
logAndProcess(w);
logAndProcess(std::move(w));
Because param is always an lvalue, process(Widget&) is always called.
11
55. Usability enhancements Type deduction Move semantics Lambda expressions
std::forward
If param’s type is an rvalue-reference, we need to cast the lvalue param as
an rvalue. This is what std::forward does.
std::move always casts as an rvalue; std::forward conditionally casts as
an rvalue.
But how to distinguish? Look at T:
1 if param is an lvalue-reference, T = Widget&;
2 if param is an rvalue-reference, T = Widget.
T must be given to std::forward so it can decide whether to cast its
parameter as an rvalue or not.
process(std::forward<T>(param));
11
56. Usability enhancements Type deduction Move semantics Lambda expressions
Subtle forwarding and rvalue references
template<typename T>
class vector {
public:
void push_back(T&& x);
};
is not a forwarding reference. Writing std::vector<Widget> v; causes
the template to be instanciated as
class vector<Widget> {
public:
void push_back(Widget&& x);
};
which involves no type deduction.
11 R
57. Usability enhancements Type deduction Move semantics Lambda expressions
Subtle forwarding and rvalue references
A template forwarding reference must have the form T&&. Hence, the two
following references do not qualify for being forwarding references.
template<typename T>
void f(const T&& param);
template<typename T>
void f(std::vector<T>&& param);
11 R
58. Usability enhancements Type deduction Move semantics Lambda expressions
Subtle forwarding and rvalue references
The variadic templates of emplace involve type deduction.
template<typename T>
class vector {
public:
template<typename... Args>
void emplace(Args&& args);
};
11 R
59. Usability enhancements Type deduction Move semantics Lambda expressions
Implementation of std::move in C++11
template<typename T>
typename remove_reference<T>::type&& move(T&& param) {
using ReturnType = typename remove_reference<T>::type&&;
return static_cast<ReturnType>(param);
}
param is a forwarding reference:
if param is an lvalue-reference, T = Widget&;
if param is an rvalue-reference, T = Widget.
Steps:
1 remove_reference<T>::type returns Widget;
2 remove_reference<T>::type&& returns Widget&&;
3 static_cast<Widget&&> casts param as an rvalue.
11 R
60. Usability enhancements Type deduction Move semantics Lambda expressions
Implementation of std::move in C++14
std::remove_reference_t<T> replaces
typename remove_reference<T>::type.
std::move can elegantly be written as
template<typename T>
decltype(auto) move(T&& param) {
using ReturnType = remove_reference_t<T>&&;
return static_cast<ReturnType>(param);
}
14 R
61. Usability enhancements Type deduction Move semantics Lambda expressions
Lambda expressions
auto lambda = [](int x, int y) -> int { return x + y; };
std::cout << lambda(2, 3) << std::endl;
Components:
(int x, int y) is the parameters list;
int after -> is the return type;
{...} is the lambda body.
A lambda can be executed upon declaration with trailing“()”:
std::cout
<< [](int x, int y) -> int { return x + y; }(2, 3)
<< std::endl;
11
62. Usability enhancements Type deduction Move semantics Lambda expressions
std::for each and std::transform
Apply a lambda to each element of an iterator:
void f(std::vector<int>& v) {
std::for_each(v.begin(), v.end(),
[](int p) { std::cout << p << std::endl; });
}
Modify each element with a lambda:
void f(std::vector<double>& v) {
std::transform(v.begin(), v.end(), v.begin(),
[](double d) { return d < 0.00001 ? 0 : d; });
}
C++03 already had std::for_each and std::transform, but
cumbersome functors were necessary since lambdas were not available.
11
63. Usability enhancements Type deduction Move semantics Lambda expressions
std::for each and std::transform
If the body is not a single return expression, the type has to be explicitely
stated:
void f(std::vector<double>& v) {
std::transform(v.begin(), v.end(), v.begin(),
[](double d) -> double {
if (d < 0.0001)
return 0;
else
return d;
});
}
11
64. Usability enhancements Type deduction Move semantics Lambda expressions
Lambda captures
[] allows to capture other variables from the scope.
void f(std::vector<double>& v, double epsilon) {
std::transform(v.begin(), v.end(), v.begin(),
[epsilon](double d) -> double {
if (d < epsilon)
return 0;
else
return d;
});
}
We can capture by both reference and value.
11
65. Usability enhancements Type deduction Move semantics Lambda expressions
Generalized lambda captures
An element of the capture can be initialized with =. This allows renaming
of variables and to capture by moving.
int x = 4;
auto y = [&r = x, x = x+1]() -> int {
r += 2;
return x+2;
}(); // Updates ::x to 6, and initializes y to 7
std::unique_ptr<int> ptr(new int(10));
auto lambda = [value = std::move(ptr)] { return *value; };
std::unique_ptr can be moved but not copied. Capture by move is the
only way to capture a std::unique_ptr.
14
66. Usability enhancements Type deduction Move semantics Lambda expressions
Generic lambdas
Lambda function parameters may be declared auto.
auto lambda = [](auto x, auto y) { return x + y; };
14
67. Usability enhancements Type deduction Move semantics Lambda expressions
Improved return type deduction
C++14 allows deduced return types for every function, not only those of
the form return expression.
void f(std::vector<double>& v, double epsilon) {
std::transform(v.begin(), v.end(), v.begin(),
[epsilon](auto d) {
if (d < epsilon)
return 0;
else
return d;
});
}
14
68. Usability enhancements Type deduction Move semantics Lambda expressions
Remaining modern C++ topics
type traits (std::enable if, std::is pointer. . . );
smart pointers;
threading facilities;
noexcept;
std::function;
std::bind and std::ref;
std::regex;
extern template;
inline namespace. . .