C++11/14 Rocks. Clang Edition. Alex Korban

Size: px
Start display at page:

Download "C++11/14 Rocks. Clang Edition. Alex Korban"

Transcription

1 C++11/14 Rocks Clang Edition Alex Korban 1

2 Contents Introduction 9 C++11 guiding principles... 9 Type Inference 11 auto Some things are still manual More than syntactic sugar Why else do we need it? Objection, Your Honor! Diving in Alittlebitofauto history decltype Side e ects declval auto, decltype -howaboutbothatonce? Lambda Expressions 22 Why do we need this thing? Return type Lambda parameters Lambda body Storing lambdas std::function to the rescue References to outside context

3 Closures Capturing in C Capturing by reference Default capture modes Capturing class members Limitations of capturing Mutable lambdas Conversion to function pointers, nested lambdas, recursion How not to shoot yourself in the foot Rules of thumb for lambdas Lambda syntax in all its glory Template Features 39 Variadic templates What else are variadic templates good for? Back to the example Working with parameter packs Traversing template parameter packs Constraining parameter packs to one type More places to expand a parameter pack Nested variadic templates Multiple parameter packs in function templates, non-type parameter packs 46 Template aliases Using using instead of typedef Closing angle brackets are o cially allowed to tail-gate Local and unnamed types as template arguments extern templates Default values for function template parameters Arbitrary expressions in template deduction contexts

4 Class Features 55 In-class initializers for non-static data members Inheriting constructors Delegating constructors Default methods Deleted methods override and final Extended friend declarations Nested class access rights The Dream of Uniform Initialization 72 Embrace the braces initializer_list Narrowing conversions Distortions of the uniformity continuum Want a move-only type in your vector? auto + {} <> + {} =? Surprising consequences of narrowing What s the verdict? Move Semantics 82 What are the benefits? How does this stu work? Revision part 1: lvalue vs. rvalue Revision part 2: const attribute + lvalue/rvalue Revision part 3: reference initialization Rvalue references

5 Overload resolution Implementing move semantics Compiler generated move operations Implementing your own move operations std::move Moving it right Rvalue references to const values Derived class construction Move construction in terms of assignment Check for self-assignment Don t make move constructors explicit Reference qualifiers for member functions Move-only types Perfect Forwarding Problem and Solution 103 Reference collapsing and rvalues in templates How the forward template works Bonus: implementation of std::move constexpr Mechanism 111 What else is it good for? What s in a constant expression? constexpr variables const and constexpr constexpr functions Literal types Acouplemorenotesonconstexpr functions Range-based for Loop 117 5

6 nullptr 120 What s the advantage over NULL? enum Changes 122 Scoped enums Specifying the underlying type Forward declaration Compile Time Assertions 127 Literals 129 Unicode support and literals Unicode character literals Raw literals User defined literals Types of literals Literal operators for integers Character and string literal operators noexcept 140 noexcept for your own functions noexcept operator When to use noexcept Acouplemorenotesonnoexcept Explicit Conversion Operators 144 Inline Namespaces 145 Why not just add a using statement?

7 Alignment 148 alignof alignas sizeof Applied to Non-static Data Members 150 Memory Model 151 Multi-threading related semantics Thread local storage 152 Thread local initialization Thread local destruction Attributes 155 Standard attributes POD Types, Trivial Types, and Standard Layout Types 157 Trivial classes Trivially copyable classes Trivial operations Standard layout types and classes Changed restrictions on unions Discriminated unions C99 Compatibility Features 165 Deprecated and Removed Features 166 C Return type deduction for functions Redeclaration

8 Generic lambdas Extended capturing in lambdas Revised restrictions on constexpr functions constexpr variable templates decltype(auto) Literals [[deprecated]] attribute Aggregate initialization Beyond C Writing Cross-Platform Code 176 Conclusion 178 Contact Information and License Agreement 179 License agreement

C++11/14 Rocks. VS2013 Edition. Alex Korban

C++11/14 Rocks. VS2013 Edition. Alex Korban C++11/14 Rocks VS2013 Edition Alex Korban 1 Contents Introduction 18 Type Inference 20 auto... 20 decltype... 24 Side e ects... 25 Trailing return types... 26 Non-standard behavior and bugs in Visual Studio

More information

C++11 and Compiler Update

C++11 and Compiler Update C++11 and Compiler Update John JT Thomas Sr. Director Application Developer Products About this Session A Brief History Features of C++11 you should be using now Questions 2 Bjarne Stroustrup C with Objects

More information

C++11 Introduction to the New Standard. Alejandro Cabrera February 1, 2012 Florida State University Department of Computer Science

C++11 Introduction to the New Standard. Alejandro Cabrera February 1, 2012 Florida State University Department of Computer Science C++11 Introduction to the New Standard Alejandro Cabrera February 1, 2012 Florida State University Department of Computer Science Overview A Brief History of C++ Features Improving: Overall Use Meta-programming

More information

C++11: 10 Features You Should be Using. Gordon R&D Runtime Engineer Codeplay Software Ltd.

C++11: 10 Features You Should be Using. Gordon R&D Runtime Engineer Codeplay Software Ltd. C++11: 10 Features You Should be Using Gordon Brown @AerialMantis R&D Runtime Engineer Codeplay Software Ltd. Agenda Default and Deleted Methods Static Assertions Delegated and Inherited Constructors Null

More information

September 10,

September 10, September 10, 2013 1 Bjarne Stroustrup, AT&T Bell Labs, early 80s cfront original C++ to C translator Difficult to debug Potentially inefficient Many native compilers exist today C++ is mostly upward compatible

More information

Introduction to C++11 and its use inside Qt

Introduction to C++11 and its use inside Qt Introduction to C++11 and its use inside Qt Olivier Goffart February 2013 1/43 Introduction to C++11 and its use inside Qt About Me http://woboq.com http://code.woboq.org 2/43 Introduction to C++11 and

More information

C++ Primer, Fifth Edition

C++ Primer, Fifth Edition C++ Primer, Fifth Edition Stanley B. Lippman Josée Lajoie Barbara E. Moo Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid Capetown Sidney Tokyo

More information

Basic Types, Variables, Literals, Constants

Basic Types, Variables, Literals, Constants Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic

More information

New wording for C++0x Lambdas

New wording for C++0x Lambdas 2009-03-19 Daveed Vandevoorde (daveed@edg.com) New wording for C++0x Lambdas Introduction During the meeting of March 2009 in Summit, a large number of issues relating to C++0x Lambdas were raised and

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

Axivion Bauhaus Suite Technical Factsheet AUTOSAR

Axivion Bauhaus Suite Technical Factsheet AUTOSAR Version 6.9.1 upwards Axivion Bauhaus Suite Technical Factsheet AUTOSAR Version 6.9.1 upwards Contents 1. C++... 2 1. Autosar C++14 Guidelines (AUTOSAR 17.03)... 2 2. Autosar C++14 Guidelines (AUTOSAR

More information

RAD Studio XE3 The Developer Force Multiplier

RAD Studio XE3 The Developer Force Multiplier RAD Studio XE3 The Developer Force Multiplier Windows 8 Mac OS X Mountain Lion C++11 64-bit Metropolis UI C99 Boost Visual LiveBindings C++ Bjarne Stroustrup C with Objects (1979) Modeled OO after Simula

More information

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns This Advanced C++ Programming training course is a comprehensive course consists of three modules. A preliminary module reviews

More information

C The new standard

C The new standard C++11 - The new standard Lars Kühne Institut für Informatik Lehrstuhl für theoretische Informatik II Friedrich-Schiller-Universität Jena January 16, 2013 Overview A little bit of history: C++ was initially

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

IBM i Version 7.3. Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC

IBM i Version 7.3. Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC IBM i Version 7.3 Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC09-7852-04 IBM i Version 7.3 Programming IBM Rational Development Studio for i ILE C/C++ Language

More information

I m sure you have been annoyed at least once by having to type out types like this:

I m sure you have been annoyed at least once by having to type out types like this: Type Inference The first thing I m going to talk about is type inference. C++11 provides mechanisms which make the compiler deduce the types of expressions. These features allow you to make your code more

More information

Problem Solving with C++

Problem Solving with C++ GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

Advanced C++ Topics. Alexander Warg, 2017

Advanced C++ Topics. Alexander Warg, 2017 www.kernkonzept.com Advanced C++ Topics Alexander Warg, 2017 M I C R O K E R N E L M A D E I N G E R M A N Y Overview WHAT IS BEHIND C++ Language Magics Object Life Time Object Memory Layout INTRODUCTION

More information

Structured bindings with polymorphic lambas

Structured bindings with polymorphic lambas 1 Introduction Structured bindings with polymorphic lambas Aaryaman Sagar (aary800@gmail.com) August 14, 2017 This paper proposes usage of structured bindings with polymorphic lambdas, adding them to another

More information

Outline. 1 Function calls and parameter passing. 2 Pointers, arrays, and references. 5 Declarations, scope, and lifetimes 6 I/O

Outline. 1 Function calls and parameter passing. 2 Pointers, arrays, and references. 5 Declarations, scope, and lifetimes 6 I/O Outline EDAF30 Programming in C++ 2. Introduction. More on function calls and types. Sven Gestegård Robertz Computer Science, LTH 2018 1 Function calls and parameter passing 2 Pointers, arrays, and references

More information

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Introduction p. xxix The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Language p. 6 C Is a Programmer's Language

More information

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. Welcome to Teach Yourself p. viii Acknowledgments p. xv Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. 6 Standard C++: A Programming Language and a Library p. 8

More information

IBM i Version 7.2. Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC

IBM i Version 7.2. Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC IBM i Version 7.2 Programming IBM Rational Development Studio for i ILE C/C++ Language Reference IBM SC09-7852-03 IBM i Version 7.2 Programming IBM Rational Development Studio for i ILE C/C++ Language

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

StroustrupReview.oo3 1/30/14 12:29:47

StroustrupReview.oo3 1/30/14 12:29:47 1 Stroustrup review - Bssic Facilities S 6. Look for the new C++11 concepts. S 7 but skim 7.3.2.1 raw string literals, skim 7.3.2.2 unicode topics, slow down and read carefully 7.7 on rvalue reference

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Ch. 10: Name Control

Ch. 10: Name Control Ch. 10: Name Control Static elements from C The static keyword was overloaded in C before people knew what the term overload meant, and C++ has added yet another meaning. The underlying concept with all

More information

Expansion statements. Version history. Introduction. Basic usage

Expansion statements. Version history. Introduction. Basic usage Expansion statements Version history Document: P1306R0 Revises: P0589R0 Date: 08 10 2018 Audience: EWG Authors: Andrew Sutton (asutton@uakron.edu) Sam Goodrick (sgoodrick@lock3software.com) Daveed Vandevoorde

More information

Modern C++, From the Beginning to the Middle. Ansel Sermersheim & Barbara Geller ACCU / C++ November 2017

Modern C++, From the Beginning to the Middle. Ansel Sermersheim & Barbara Geller ACCU / C++ November 2017 Modern C++, From the Beginning to the Middle Ansel Sermersheim & Barbara Geller ACCU / C++ November 2017 1 Introduction Where is the Beginning Data Types References Const Const Const Semantics Templates

More information

CS 485 Advanced Object Oriented Design C++ Lambda, Function Objects, Brace Initializers constexpr, Move Constructors/Rvalue references.

CS 485 Advanced Object Oriented Design C++ Lambda, Function Objects, Brace Initializers constexpr, Move Constructors/Rvalue references. CS 485 Advanced Object Oriented Design C++ Lambda, Function Objects, Brace Initializers constexpr, Move Constructors/Rvalue references Spring 2017 Meyers 7,15, 31-34 Reading Inline Functions Declare function

More information

Type Inference auto for Note: Note:

Type Inference auto for Note: Note: Type Inference C++11 provides mechanisms for type inference which make the compiler deduce the types of expressions. I m starting the book with type inference because it can make your code more concise

More information

std::optional from Scratch

std::optional from Scratch std::optional from Scratch https://wg21.link/n4606 http://en.cppreference.com/w/cpp/utility/optional http://codereview.stackexchange.com/questions/127498/an-optionalt-implementation An optional object

More information

CS

CS CS 1666 www.cs.pitt.edu/~nlf4/cs1666/ Programming in C++ First, some praise for C++ "It certainly has its good points. But by and large I think it s a bad language. It does a lot of things half well and

More information

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

Practical C++ Programming

Practical C++ Programming SECOND EDITION Practical C++ Programming Steve Oualline O'REILLY' Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo Preface xv Part I. The Basics 1. What Is C++? 3 A Brief History of C++ 3 C++

More information

Using Enum Structs as Bitfields

Using Enum Structs as Bitfields New York C++ Developers Group July 12, 2016 Using Enum Structs as Bitfields Presentation by Jon Kalb Based on an article in Overload magazine by Anthony Williams 1 What do these have in common?! explicit

More information

Remedial C Now that we can actually use it Pete Williamson

Remedial C Now that we can actually use it Pete Williamson Remedial C++ 11 Now that we can actually use it Pete Williamson (petewil00@hotmail.com) Overview (1) auto lambdas nullptr = default, = delete shared_ptr Range based for loops Overview (2) Uniform initialization

More information

Generalized Constant Expressions

Generalized Constant Expressions Doc. no. Date: September 21, 2003 Reply-To: Gabriel Dos Reis gdr@acm.org Abstract We suggest to generalize the notion of constant expressions to include calls to constant-valued functions. The purpose

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

Rvalue References & Move Semantics

Rvalue References & Move Semantics Rvalue References & Move Semantics PB173 Programming in Modern C++ Nikola Beneš, Vladimír Štill, Jiří Weiser Faculty of Informatics, Masaryk University spring 2016 PB173 Modern C++: Rvalue References &

More information

From Wikipedia, the free encyclopedia

From Wikipedia, the free encyclopedia 1 of 42 10/20/2011 07:32 PM C++11 From Wikipedia, the free encyclopedia C++11, also formerly known as C++0x (pronounced "see plus plus oh ex"), [1] is the name of the most recent iteration of the C++ programming

More information

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

Recap: Pointers. int* int& *p &i &*&* ** * * * * IFMP 18, M. Schwerhoff

Recap: Pointers. int* int& *p &i &*&* ** * * * * IFMP 18, M. Schwerhoff Recap: Pointers IFMP 18, M. Schwerhoff int* int& *p &i &*&* ** * * * * A 0 A 1 A 2 A 3 A 4 A 5 A 0 A 1 A 2 A 3 A 4 A 5 5 i int* p; A 0 A 1 A 2 A 3 A 4 A 5 5 i p int* p; p = &i; A 0 A 1 A 2 A 3 A 4 A 5

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

Other C++11/14 features

Other C++11/14 features Other C++11/14 features Auto, decltype Range for Constexpr Enum class Initializer list Default and delete functions Etc. Zoltán Porkoláb: C++11/14 1 Auto, decltype template void printall(const

More information

Advanced Programming & C++ Language

Advanced Programming & C++ Language Advanced Programming & C++ Language ~10~ C++11 new features Ariel University 2018 Dr. Miri (Kopel) Ben-Nissan 2 Evolution of C++ Language What is C++11? 3 C++11 is the ISO C++ standard formally ratified

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer May 13, 2013 OOPP / C++ Lecture 7... 1/27 Construction and Destruction Allocation and Deallocation Move Semantics Template Classes Example:

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter

More information

Fast Introduction to Object Oriented Programming and C++

Fast Introduction to Object Oriented Programming and C++ Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming

More information

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309 A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48

More information

Extending SystemVerilog Data Types to Nets

Extending SystemVerilog Data Types to Nets Extending SystemVerilog Data Types to Nets SystemVerilog extended Verilog by adding powerful new data types and operators that can be used to declare and manipulate parameters and variables. Extensions

More information

Ch. 12: Operator Overloading

Ch. 12: Operator Overloading Ch. 12: Operator Overloading Operator overloading is just syntactic sugar, i.e. another way to make a function call: shift_left(42, 3); 42

More information

Introduction to Move Semantics in C++ C and C

Introduction to Move Semantics in C++ C and C Introduction to Move Semantics in C++ C++ 2011 and C++ 2014 Jean-Paul RIGAULT University of Nice - Sophia Antipolis Engineering School Computer Science Department Sophia Antipolis, France Contents of the

More information

Overload Resolution. Ansel Sermersheim & Barbara Geller Amsterdam C++ Group March 2019

Overload Resolution. Ansel Sermersheim & Barbara Geller Amsterdam C++ Group March 2019 Ansel Sermersheim & Barbara Geller Amsterdam C++ Group March 2019 1 Introduction Prologue Definition of Function Overloading Determining which Overload to call How Works Standard Conversion Sequences Examples

More information

10. Functions (Part 2)

10. Functions (Part 2) 10.1 Overloaded functions 10. Functions (Part 2) In C++, two different functions can have the same name if their parameters are different; either because they have a different number of parameters, or

More information

COMP6771 Advanced C++ Programming

COMP6771 Advanced C++ Programming 1. COMP6771 Advanced C++ Programming Week 4 Part One: (continued) and 2016 www.cse.unsw.edu.au/ cs6771 2. Inline Constructors, Accessors and Mutators Question (from 2015): In the week 3 examples, constructors

More information

CHAPTER 1: A CRASH COURSE IN C++ 3 CHAPTER 2: DESIGNING PROFESSIONAL C++ PROGRAMS 49

CHAPTER 1: A CRASH COURSE IN C++ 3 CHAPTER 2: DESIGNING PROFESSIONAL C++ PROGRAMS 49 INTRODUCTION xxv PART I: INTRODUCTION TO PROFESSIONAL C++ CHAPTER 1: A CRASH COURSE IN C++ 3 The Basics of C++ 3 The Obligatory Hello, World 4 Namespaces 7 Variables 8 Operators 11 Types 13 Conditionals

More information

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,

More information

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi Outline Move semantics Classes Operator overloading Making your class copyable Making your class movable Rule of all or nothing Inheritance

More information

Adding Alignment Support to the C++ Programming Language / Wording

Adding Alignment Support to the C++ Programming Language / Wording Doc No: SC22/WG21/N2165 J16/07-0025 of project JTC1.22.32 Address: LM Ericsson Oy Ab Hirsalantie 11 Jorvas 02420 Date: 2007-01-14 to 2007.01.15 04:53:00 Phone: +358 40 507 8729 (mobile) Reply to: Attila

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

Object-Oriented Programming for Scientific Computing

Object-Oriented Programming for Scientific Computing Object-Oriented Programming for Scientific Computing Dynamic Memory Management Ole Klein Interdisciplinary Center for Scientific Computing Heidelberg University ole.klein@iwr.uni-heidelberg.de 2. Mai 2017

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

Programming Language C++11. Summary of changes and general feature description. Niedl, Markus

Programming Language C++11. Summary of changes and general feature description. Niedl, Markus Programming Language Summary of changes and general feature description. Niedl, Markus Markus.Niedl@gmx.net 2012-09-25 Contents 1 Preamble... 4 2 Abstract... 4 3 Changes from the previous version of the

More information

IBM Rational Rhapsody TestConductor Add On. Code Coverage Limitations

IBM Rational Rhapsody TestConductor Add On. Code Coverage Limitations IBM Rational Rhapsody TestConductor Add On Code Coverage Limitations 1 Rhapsody IBM Rational Rhapsody TestConductor Add On Code Coverage Limitations Release 2.7.1 2 License Agreement No part of this publication

More information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

Qualified std::function signatures

Qualified std::function signatures Document number: P0045R1 Date: 2017 02 06 To: SC22/WG21 LEWG Reply to: David Krauss (david_work at me dot com) Qualified std::function signatures std::function implements type-erasure of the behavior of

More information

Coroutine concepts and metafunctions

Coroutine concepts and metafunctions Document No. P1288R0 Date 2018-10-07 Reply To Audience Lewis Baker SG1, LEWG Coroutine concepts and metafunctions Abstract The Coroutines TS introduces the ability to co_await a value from

More information

Overview. 1. Expression Value Categories 2. Rvalue References 3. Templates 4. Miscellaneous Hilarity 2/43

Overview. 1. Expression Value Categories 2. Rvalue References 3. Templates 4. Miscellaneous Hilarity 2/43 Advanced C++ 1/43 Overview 1. Expression Value Categories 2. Rvalue References 3. Templates 4. Miscellaneous Hilarity 2/43 1. Expression Value Categories These are not the droids you re looking for ~Obi-wan

More information

Object-Oriented Programming

Object-Oriented Programming - oriented - iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 56 Overview - oriented 1 2 -oriented 3 4 5 6 7 8 Static and friend elements 9 Summary 2 / 56 I - oriented was initially created by Bjarne

More information

C-LANGUAGE CURRICULAM

C-LANGUAGE CURRICULAM C-LANGUAGE CURRICULAM Duration: 2 Months. 1. Introducing C 1.1 History of C Origin Standardization C-Based Languages 1.2 Strengths and Weaknesses Of C Strengths Weaknesses Effective Use of C 2. C Fundamentals

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer October 10, 2016 OOPP / C++ Lecture 7... 1/15 Construction and Destruction Kinds of Constructors Move Semantics OOPP / C++ Lecture 7... 2/15

More information

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking Agenda COMP 181 Type checking October 21, 2009 Next week OOPSLA: Object-oriented Programming Systems Languages and Applications One of the top PL conferences Monday (Oct 26 th ) In-class midterm Review

More information

MODERNIZATION C++ Bjarne Stroustrup, creator of C++

MODERNIZATION C++ Bjarne Stroustrup, creator of C++ C++ MODERNIZATION New releases of the C++ language maintain incredibly strong backwards compatibility, making it easy to keep older C++ code working properly as standards march forward. This makes C++

More information

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,

More information

Index. Symbols. bit sequence, 27 ^ (exclusive OR) operator, 30 hexadecimal number, 27 left shift (<<) operator, 31 right shift (>>) operator, 32

Index. Symbols. bit sequence, 27 ^ (exclusive OR) operator, 30 hexadecimal number, 27 left shift (<<) operator, 31 right shift (>>) operator, 32 Symbols && operator, 32 operator, 32 A AddDynamicOption method, 188 AddItem method, 192 Addition operator, 18 Allocating memory, 228 overloaded delete function, 233 overloaded new function, 232 unnamed

More information

QUIZ. What is wrong with this code that uses default arguments?

QUIZ. What is wrong with this code that uses default arguments? QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code

More information

Overload Resolution. Ansel Sermersheim & Barbara Geller ACCU / C++ June 2018

Overload Resolution. Ansel Sermersheim & Barbara Geller ACCU / C++ June 2018 Ansel Sermersheim & Barbara Geller ACCU / C++ June 2018 1 Introduction Definition of Function Overloading Determining which Overload to call How Overload Resolution Works Standard Conversion Sequences

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

Rvalue References as Funny Lvalues

Rvalue References as Funny Lvalues I. Background Document: Author: Date: 2009-11-09 Revision: 1 PL22.16/09-0200 = WG21 N3010 William M. Miller Edison Design Group Rvalue References as Funny Lvalues Rvalue references were introduced into

More information

Working Draft, Extensions to C++ for Modules

Working Draft, Extensions to C++ for Modules Document Number: Date: 2017-03-19 Revises: N4637 Reply to: Gabriel Dos Reis Microsoft gdr@microsoft.com Working Draft, Extensions to C++ for Modules Note: this is an early draft. It s known to be incomplet

More information

Adding Alignment Support to the C++ Programming Language / Consolidated

Adding Alignment Support to the C++ Programming Language / Consolidated Doc No: SC22/WG21/N2140 J16/06-0210 of project JTC1.22.32 Address: LM Ericsson Oy Ab Hirsalantie 1 Jorvas 02420 Date: 2006-11-05 to 2006.11.06 21:55:00 Phone: +358 40 507 8729 (mobile) Reply to: Attila

More information

Programming. Principles and Practice Using C++ Bjarne Stroustrup. / Addison-Wesley. Second Edition

Programming. Principles and Practice Using C++ Bjarne Stroustrup. / Addison-Wesley. Second Edition Programming Principles and Practice Using C++ Second Edition Bjarne Stroustrup / Addison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid

More information

Variables. Data Types.

Variables. Data Types. Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting

More information

The Design Process. General Development Issues. C/C++ and OO Rules of Thumb. Home

The Design Process. General Development Issues. C/C++ and OO Rules of Thumb. Home A l l e n I. H o l u b & A s s o c i a t e s Home C/C++ and OO Rules of Thumb The following list is essentially the table of contents for my book Enough Rope to Shoot Yourself in the Foot (McGraw-Hill,

More information

Move semantics. Zoltán Porkoláb: C++11/14 1

Move semantics. Zoltán Porkoláb: C++11/14 1 Move semantics Pointers and arrays References Value vs move semantics Right value references Move semantics in C++11 Perfect forwarding Traps and pitfalls Zoltán Porkoláb: C++11/14 1 Arrays An array is

More information

American National Standards Institute Reply to: Josee Lajoie

American National Standards Institute Reply to: Josee Lajoie Accredited Standards Committee X3 Information Processing Systems Operating under the procedures of American National Standards Institute Doc No: X3J16/95-0051 WG21/N0651 Date: March 3, 1995 Page 1 of 15

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer September 26, 2016 OOPP / C++ Lecture 4... 1/33 Global vs. Class Static Parameters Move Semantics OOPP / C++ Lecture 4... 2/33 Global Functions

More information

CPSC 427: Object-Oriented Programming

CPSC 427: Object-Oriented Programming CPSC 427: Object-Oriented Programming Michael J. Fischer Lecture 11 October 3, 2018 CPSC 427, Lecture 11, October 3, 2018 1/24 Copying and Assignment Custody of Objects Move Semantics CPSC 427, Lecture

More information

Rvalue References, Move Semantics, Universal References

Rvalue References, Move Semantics, Universal References Rvalue References, Move Semantics, Universal References PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill Faculty of Informatics, Masaryk University Spring 2018 PV264: Rvalue References,

More information

GO MOCK TEST GO MOCK TEST I

GO MOCK TEST GO MOCK TEST I http://www.tutorialspoint.com GO MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Go. You can download these sample mock tests at your local machine

More information

A Crash Course in (Some of) Modern C++

A Crash Course in (Some of) Modern C++ CMPT 373 Software Development Methods A Crash Course in (Some of) Modern C++ Nick Sumner wsumner@sfu.ca With material from Bjarne Stroustrup & Herb Sutter C++ was complicated/intimidating Pointers Arithmetic

More information

index C++ language characters ASCII codes, 16 escape sequence, 19 trigraph sequence, 18 UCS codes, 17 Unicode, 17 classes, 7 code presentation styles,

index C++ language characters ASCII codes, 16 escape sequence, 19 trigraph sequence, 18 UCS codes, 17 Unicode, 17 classes, 7 code presentation styles, Index A Abstract class Circle class creation, 454 constructor, 453 data member, 457 definition, 453 interface, 455 three-level class hierarchy, 458 Vessel class, 456 457 volume() function, 454 455 Access

More information