REFLECTIVE METAPROGRAMMING IN C++ Дэвид Вандевурд Edison Design Group

Size: px
Start display at page:

Download "REFLECTIVE METAPROGRAMMING IN C++ Дэвид Вандевурд Edison Design Group"

Transcription

1 REFLECTIVE METAPROGRAMMING IN C++ Дэвид Вандевурд Edison Design Group

2 REFLECTIVE METAPROGRAMMING IN C++ Daveed Vandevoorde Edison Design Group

3 WHAT IS REFLECTIVE METAPROGRAMMING?

4 REFLECTION

5 REFLECTION CODE struct S { int f(); }; int S::f(int x) { return x; } using Magic = S; DATA S: type kind: struct members: function: f type: int (int) defined: true Magic: alias type: S

6 METAPROGRAMMING auto stream_out(stream &strm)->bool { strm << "entity: " << "type/struct" << '\n'; strm << "{\n"; strm << "member: ";

7 REFLECTIVE METAPROGRAMMING Code Generation Program Code Reflection Data

8 REFLECTIVE METAPROGRAMMING Internal vs. External Compile-time vs. Run-time

9 REFLECTIVE METAPROGRAMMING Example 1 Generate a serialization function given a type.

10 REFLECTIVE METAPROGRAMMING Example 2 Generate strings given enumerator constants.

11 REFLECTIVE METAPROGRAMMING Example 3 Create a "struct of vectors" from a struct. Give it a std::vector-like interface.

12 REFLECTIVE METAPROGRAMMING Example 4 Herb Sutter's metaclasses.

13 A TASTE OF TEMPLATE METAPROGRAMMING

14 TYPE FUNCTIONS template<typename T> struct AddPtrT { using Type = T*; }; template<typename T> using AddPtr = typename AddPtrT<T>::Type; AddPtr<AddPtr<int>> ppi; // Same as "int** ppi;" AddPtr is a template meta-function.

15 HIGHER-ORDER FUNCTIONS template<typename T, template<typename> typename F, int N> struct RepeatT { using ArgT = typename RepeatT<T, F, N-1>::Type; using Type = typename F<ArgT>::Type; }; template<typename T, template<typename> typename F> struct RepeatT<T, F, 0> { using Type = T; }; template<typename T, int N> struct AddNPtrT { using Type = typename RepeatT<T, AddPtrT, N>::Type; }; template<typename T, int N> using AddNPtr = typename AddNPtrT<T, N>::Type; AddNPtr<int, 4> ppppi; // Same as "int ****ppppi;"

16 CONTAINERS // Container of types. template<typename... Ts> struct Seq {}; template<int I, typename S> struct IdxT; // Metafunction to get I-th element from sequence S. template<int I, typename S> using Idx = typename IdxT<I, S>::Type; // Container of nontypes. template<typename T, T... Ns> struct ValSeq {}; template<int... Ns> using IdxSet = ValSeq<int, Ns...>; template<int N> using MakeIdxSeq = make_integer_seq<valseq, int, N>; // Alias for IdxSeq<0, 1,..., N-1>.

17 AN IMPLEMENTATION OF IdxT template<typename T> struct IdentT { using Type = T; }; template<typename> struct IdxTHelper; template<int... Skips> struct IdxTHelper<IdxSet<Skips...>> { template<typename T> static T f(decltype(skips, (void*)0)..., T*,...); }; template<int I, typename... T> struct IdxT<I, Seq<T...>> { using Type = typename decltype( IdxTHelper<MakeIdxSeq<I>>::f((IdentT<T>*)(0)...) )::Type; };

18 REFLECTION template<typename T> struct IsFunction { static constexpr bool value = false; static constexpr bool varargs = false; }; template<typename RT, typename PTs...> struct IsFunction<RT(PTs...)> { static constexpr bool value = true; static constexpr bool varargs = false; }; template<typename RT, typename PTs...> struct IsFunction<RT(PTs...,...)> { static constexpr bool value = true; static constexpr bool varargs = true; };

19 SFINAE (SUBSTITUTION FAILURE IS NOT AN ERROR) template<typename T, bool Cond> struct EnableIfT; template<typename T> struct EnableIfT<T, true> { using Type = T; }; template<typename T, bool Cond> using EnableIf = typename EnableIfT<T, Cond>::Type; template<typename... Ts> EnableIf<void, (sizeof...(ts)%2)> pack_func(seq<ts...>); template<typename... Ts> EnableIf<void,!(sizeof...(Ts)%2)> pack_func(seq<ts...>);

20 EXPRESSION TEMPLATES template<typename T, typename Repr = Storage<T>> struct Array {... }; //... template<typename T, typename R1, typename R2> inline Array<T, XAdd<R1, R2>> operator+(array<t, R1> const &p, Array<T, R2> const &q) { return Array<T, XAdd<R1, R2>>( XAdd<R1, R2>(p.repr(), q.repr())); } //... x = 3*y+z; // Array<int, XAdd<XScale<Storage<int>>, Storage<int>>>

21 A BIT OF HISTORY

22 1988: TEMPLATES "PARAMETERIZED TYPES FOR C++" USENIX CONFERENCE

23

24

25

26 1993: BORLAND C++ 4.0

27 MARCH 1994: ERWIN UNRUH

28 1995: TODD VELDHUIZEN

29 1998: ISO C++

30

31 (THE COMPLETE GUIDE)

32 2002: SFINAE REVEALED

33 2003: ENABLE_IF Järvi, Willcock, Hinnant, and Lumsdaine

34 2011: C++11

35 2012: RELAXED CONSTEXPR

36 2013: GENERIC LAMBDAS

37 2013: RETURN DEDUCTION

38 2014: C++14

39 BOOST.HANA

40 THE 3 AXES OF REFLECTIVE METAPROGRAMMING

41 1. REFLECTION

42 2. SYNTHESIS & REIFICATION

43 3. CONTROL

44 SG7

45 P0194: STATIC REFLECTION Chochlík, Naumann, and Sankel :

46 P0194: STATIC REFLECTION New reflexpr construct: meta-types. Rich set of meta-operations. Ties naturally into template metaprogramming (also, Boost.Hana). Limited reification, but extensions considered (e.g., unreflexpr). Scheduled for TS status.

47 P0194: STATIC REFLECTION using namespace meta =...; template<typename H, typename S> requires HashAlgorithm<H> && SimpleStruct<S> void hash_append(h &h, S const &s) { meta::for_each<meta::get_data_members_t<reflexpr(s)>>( [&](auto meta_mem) { using MetaMem = typename decltype(meta_mem)::type; auto data_mem = meta::get_pointer_v<metamem>; } ); hash_append(h, s.*data_mem); }

48 P0194: STATIC REFLECTION Problems: Types as values are not intuitive. Notation is heterogeneous: <...> and (...). Poor, non-scaling compile-time.

49 P0598: REFLECT THROUGH VALUES Vandevoorde

50 P0598: REFLECT THROUGH VALUES Use a single value type for reflected metainformation. Use constexpr evaluation for control. Code looks like ordinary C++. Values are ephemeral in the compiler: Scalable. Endorsed by SG7 as the preferred direction for standard reflective metaprogramming.

51 P0598: REFLECT THROUGH VALUES Problem space/applications explored by Louis Dionne. Now basis for Herb Sutter's metaclasses. Implementation by Andrew Sutton. Sutton, Sutter

52 P0598: REFLECT THROUGH VALUES Problems: Synthesis/Reification? Constexpr extensions needed.

53 P0598: REFLECT THROUGH VALUES using namespace meta =...; template<typename H, typename S> requires HashAlgorithm<H> && SimpleStruct<S> void hash_append(h &h, S const &s) { constexpr { for (meta::info m : meta::data_members(reflexpr(s))) { } } -> { hash_append(h, s.(.m.)); } }

54 WHAT IS META::INFO? A "small" literal type, usable as a template argument. Effectively an opaque index into the AST. Could be an enum type. Ideally, wouldn't leak into run-time space. (Although harmless if an enum type.) See also P0993 by Sutton and Sutter.

55 HOW TO GET META::INFO VALUES? Using the new reflexpr operator, or by applying "immediate" functions to meta::info objects. E.g.: meta::info t1 = reflexpr(meta::info); meta::info t2 = meta::parent_of(t1); Handling meta::parent_of(reflexpr(int))? Constexpr containers/ranges of meta::info values? Functionality guided by P0194.

56 HOW TO REIFY META::INFO VALUES? Let i be a meta::info value: typename(i), namespace(i), template(i) Expression: (.i.) Template argument: (<i>) Also applicable to meta::info ranges: Produces a pack. E.g.: auto args = meta::template_args_of(i); S<(<args>)...> s;

57 SYNTHESIS? Reification + template instantiation Feasible, but limited. Perhaps extensible (new instantiation kinds). Insert strings as source Very powerful, but difficult to debug. Token stream injection Powerful and readable. Current basis of Herb Sutter's metaclasses. Controversial.

58 REIFICATION + TEMPLATE INSTANTIATION using namespace meta =...; template<typename H, typename S> requires HashAlgorithm<H> && SimpleStruct<S> void hash_append(h &h, S const &s) { constexpr { auto members = meta::data_members(reflexpr(s)); (hash_append(h, s.(.members.)),...); } } C++17 fold-expression!

59 INSERT STRINGS AS SOURCE template<typename H, typename S> requires HashAlgorithm<H> && SimpleStruct<S> void hash_append(h &h, S const &s) { constexpr { for (meta::info m : meta::data_members(reflexpr(s))) { meta::queue( meta::code( hash_append(h, s., meta::name(m), ); ), meta::full_name(m)); // Debugging aid. } } }

60 TOKEN STREAM INJECTION using namespace meta =...; template<typename H, typename S> requires HashAlgorithm<H> && SimpleStruct<S> void hash_append(h &h, S const &s) { constexpr { for (meta::info m : meta::data_members(reflexpr(s))) { } } -> { hash_append(h, s.(.m.)); } }

61 TOKEN STREAM INJECTION -> {... } -> class {... } -> namespace {... } -> namespace N {... } -> (my_metainfo) {... }

62 CONSTEXPR EXTENSIONS

63 C++20: DYNAMIC ALLOCATION Dionne, Ranns, Smith, Vandevoorde

64 THANK YOU, ANTONY POLUKHIN

65 C++20: DYNAMIC ALLOCATION constexpr int sum(int n) { int *p = new int[n]; // Dynamic allocation! int sum = 0; for (int k = 0; k<n; ++k) { p[k] = k; sum += p[k]; } delete[] p; return sum; // No dynamic allocation left. } constexpr int r = sum(13); // Okay!

66 C++20: DYNAMIC ALLOCATION #include <memory> template<typename T> using Alloc = std::allocator<t>; constexpr int sum(int n) { Alloc<int> a; int *p = a.allocate(n); int sum = 0; for (int k = 0; k<n; ++k) { std::allocator_traits<alloc>::construct(a, &p[k], k); // Okay! sum += p[k]; } a.deallocate(p); return sum; // No dynamic allocation left. } constexpr int r = sum(13); // Okay!

67 C++20: DYNAMIC ALLOCATION #include <memory> template<typename T> using Alloc = std::allocator<t>; struct Summer { [[no_unique_address]] Alloc<int> alloc; int n, *p; constexpr Summer(int n): alloc(), n(n), p(alloc.allocate(n)) { for (int k = 0; k<n; ++k) p[k] = k; } int result() const { int sum = 0; for (int k = 0; k<n; ++k) sum += p[k]; return sum; } constexpr ~Summer() { alloc.deallocate(p, n); } // constexpr destructor! }; constexpr int sum(int n) { return Summer<int>(n).result(); // No dynamic allocation left. } constexpr int r = sum(13); // Okay!

68 CONSTEXPR STANDARD CONTAINERS

69 CONSTEXPR STANDARD CONTAINERS P0784 provides the basic tools to enable some standard containers, like std::vector...

70 CONSTEXPR STANDARD CONTAINERS #include <vector> constexpr int sum(int n) { std::vector<int> v(n); int sum = 0; for (int k = 0; k<n; ++k) { v[k] = k; sum += v[k]; } return sum; } // No dynamic allocation left. constexpr int r = sum(13); // Okay!

71 CONSTEXPR STANDARD CONTAINERS #include <string> constexpr int length(char const *ntbs) { std::string s(ntbs); return (int)s.length(); } // No dynamic allocation left. constexpr int r = length("c++ Russia"); // Okay? This is a little tricky because of the "short string" optimization. Standard library writers need an additional tool...

72 CONSTEXPR EVALUATION DETECTION

73 CONSTEXPR EVALUATION DETECTION constexpr unsigned ones(unsigned word) { if (std::in_constexpr_call()) { unsigned result = 0; for (; word!= 0; word >>= 1) { if (word & 1) result += 1; } return result; } else { asm ("..."); } } unsigned two = ones(5u); // std::in_constexpr_call() == true unsigned three = ones(7u); // std::in_constexpr_call() == true unsigned fifteen = 15U; unsigned four = ones(fifteen); // std::in_constexpr_call() == false unsigned five() { return ones(0x57u); // std::in_constexpr_call() could be either }

74 CONSTEXPR EVALUATION DETECTION std::string() can use this to disable the short-string optimization during constant expression evaluations. (Thank you, LEWG.)

75 STORAGE PROMOTION

76 STORAGE PROMOTION #include <vector> constexpr std::vector<int> series(int n) { std::vector<int> v(n); for (int k = 0; k<n; ++k) { v[k] = k; } return v; } // Leftover dynamic storage!! constexpr auto vec = series(10); //?? 1. Constexpr-evaluate the destructor. 2. If successful and leftover storage is deallocated, then promote the leftover storage to the variable's storage duration, and discard the run-time destructor invocation.

77 STORAGE PROMOTION #include <vector> constexpr std::vector<int> series(int n) { std::vector<int> v(n); for (int k = 0; k<n; ++k) { v[k] = k; } return v; } // Leftover dynamic storage!! constexpr auto vec = series(10); // Okay! 1. Constexpr-evaluate the destructor. 2. If successful and leftover storage is deallocated, then promote the leftover storage to the variable's storage duration, and discard the run-time destructor invocation.

78 CONSTEXPR!

79 CONSTEXPR! constexpr! int sqr(int n) { return n*n; } constexpr int n1 = sqr(128); // Okay. int x = 1000; int n2 = sqr(x); // Error: Call does not evaluate to a // constant!

80 CONSTEXPR! constexpr! int sqr(int n) { return n*n; } constexpr! int sqrsqr(int n) { return sqr(sqr(n)); // Okay, because in "constexpr!" } // function. constexpr int sixteen = sqrsqr(2); constexpr int dblsqr(int n) { return 2*sqr(n); // Error: "sqr(n)" is not a constant. }

81 CONSTEXPR! constexpr! int ft = 42; // Never an lvalue. int f(int const &p) { return 2*p; } int r = f(ft); // ft initializes a temporary! // No direct binding.

82 2003: ACCU METACODE

83 Reflective Metaprogramming in C++ Daveed Vandevoorde Edison Design Group

84 2003: ACCU METACODE

85 Programming/C++ Templates are among the most powerful features of C++, but they remain misunderstood and underutilized, even as the C++ language and development community have advanced. In C++ Templates, Second Edition, three pioneering C++ experts show why, when, and how to use modern templates to build software that s cleaner, faster, more efficient, and easier to maintain. Now extensively updated for the C++11, C++14, and C++17 standards, this new edition presents state-of-the-art techniques for a wider spectrum of applications. The authors provide authoritative explanations of all new language features that either improve templates or interact with them, including variadic templates, generic lambdas, class template argument deduction, compile-time if, inline namespaces, and user-defined literals. They also deeply delve into fundamental language concepts (like value categories) and fully cover all standard type traits. The book starts with an insightful tutorial on basic concepts and relevant language features. The remainder of the book serves as a comprehensive reference, focusing first on language details and then on coding techniques, advanced applications, and sophisticated idioms. Throughout, examples clearly illustrate abstract concepts and demonstrate best practices for exploiting all that C++ templates can do. ++ Understand exactly how templates behave, and avoid common pitfalls ++ Use templates to write more efficient, flexible, and maintainable software ++ Master today s most effective idioms and techniques The companion website, tmplbook.com, contains sample code and additional updates. David Vandevoorde, vice president of engineering at Edison Design Group, Inc., architects key features of the company s C++ compiler. A co-founder of the renowned comp.lang.c++.moderated forum, he is also active in C++ standardization. He holds a PhD and MSc in computer science from Rensselaer Polytechnic Institute, and an MEng from Brussels Free University. His technical interests include algorithm development and teaching. Nicolai M. Josuttis is an independent systems architect, technical manager, consultant, and trainer, and has been active in C++ standardization for 20 years. Sitting in the Library Working Group he especially cares for the view of the ordinary application programmer. He is well known in the C++ community for speaking and writing with authority, being the author of The C++ Standard Library A Tutorial and Reference, Second Edition (Addison-Wesley, 2012), and other books. Douglas Gregor is a senior compiler developer with a background in C++ library design. As an early contributor to Boost, he developed several libraries that became part of the C++ standard. Later, he led the implementation of the open source Clang C++ compiler as its code owner through the completion of C++11 support, and was active in the standardization of C++11. He holds a PhD in computer science from Rensselaer Polytechnic Institute. informit.com/aw informit.com/cplusplus tmplbook.com ++ Reuse source code without compromising performance or safety ++ Benefit from utilities for generic programming in the C++ Standard Library ++ Preview the upcoming concepts feature Cover illustration: Aleksander Erin/ShutterStock Text printed on recycled paper ISBN-13: ISBN-10: $79.99 U.S. $99.99 Canada GREGOR JOSUTTIS VANDEVOORDE C++ The Complete Guide Templates SECOND EDITION Covers C ++11, C ++14, and C ++17 C++ Templates The Complete Guide SECOND EDITION David VANDEVOORDE Nicolai M. JOSUTTIS Douglas GREGOR

86 THE END

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

Lambdas in unevaluated contexts

Lambdas in unevaluated contexts Lambdas in unevaluated contexts Document #: P0315R2 Date: 2017-06-18 Project: Programming Language C++ Audience: Core Working Group Reply-to: Louis Dionne Hubert Tong

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

Lambdas in unevaluated contexts

Lambdas in unevaluated contexts Lambdas in unevaluated contexts Document #: P0315R1 Date: 2016-08-01 Project: Programming Language C++ Evolution Group Reply-to: Louis Dionne 1 Revision history R0 Initial draft R1

More information

Haskell and C++ Template Metaprogramming. Bartosz Milewski

Haskell and C++ Template Metaprogramming. Bartosz Milewski Haskell and C++ Template Metaprogramming Bartosz Milewski Why Haskell? Easy syntax Almost one-to-one match with C++ TMP Differences Runtime vs. compile-time Regular data vs. types Plan Functions and Metafunctions

More information

Implementing language support for compile-time metaprogramming

Implementing language support for compile-time metaprogramming Document P0712R0 Date 2017-06-18 Audience SG-7 Reply-to Andrew Sutton Herb Sutter Implementing language support for compile-time metaprogramming Table of Contents

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

Debug C++ Without Running. Anastasia Kazakova

Debug C++ Without Running. Anastasia Kazakova Debug C++ Without Running Anastasia Kazakova JetBrains @anastasiak2512 Agenda 1. Tricky C++ language. Show samples! 2. Seems to help but it doesn t. Why? Running / Debugging Static / dynamic code analysis

More information

Part X. Advanced C ++

Part X. Advanced C ++ Part X Advanced C ++ topics Philip Blakely (LSC) Advanced C++ 158 / 217 References The following are highly regarded books. They are fairly in-depth, and I haven t read them in their entirity. However,

More information

Wording for lambdas in unevaluated contexts

Wording for lambdas in unevaluated contexts Wording for lambdas in unevaluated contexts Document #: P0315R4 Date: 2017-11-10 Project: Programming Language C++ Audience: Core Working Group Reply-to: Louis Dionne Hubert Tong

More information

template <typename T> // unless it s an unqualified pointer struct IsPtr<T *> { enum { r = true }; };

template <typename T> // unless it s an unqualified pointer struct IsPtr<T *> { enum { r = true }; }; SFINAE Sono Buoni SFINAE In attempting to use function template argument deduction to select among a number of candidate function templates, a C++ compiler may attempt an instantiation that fails on one

More information

Class Types in Non-Type Template Parameters

Class Types in Non-Type Template Parameters Class Types in Non-Type Template Parameters Document #: D0732R0 Date: 2017-11-11 Project: Programming Language C++ Audience: Evolution Reply-to: Jeff Snyder 1 TL;DR We should

More information

TDDD38 - Advanced programming in C++

TDDD38 - Advanced programming in C++ TDDD38 - Advanced programming in C++ Templates III Christoffer Holm Department of Computer and information science 1 Dependent Names 2 More on Templates 3 SFINAE 1 Dependent Names 2 More on Templates 3

More information

@odinthenerd. not the god. Auto-Intern GmbH 1

@odinthenerd. not the god. Auto-Intern GmbH 1 @odinthenerd not the god Auto-Intern GmbH 1 Auto-Intern GmbH 2 You are awesome! I m not impressed Auto-Intern GmbH 3 You are awesome! I m not impressed Auto-Intern GmbH 4 You are awesome! I m not impressed

More information

Programming at Compile Time. Rainer Grimm Training, Coaching, and Technology Consulting

Programming at Compile Time. Rainer Grimm Training, Coaching, and Technology Consulting Programming at Compile Time Rainer Grimm Training, Coaching, and Technology Consulting www.modernescpp.de Overview Constant expressions Type-traits library Template metaprogramming Template Metaprogramming

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

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

On the correctness of template metaprograms

On the correctness of template metaprograms Proceedings of the 7 th International Conference on Applied Informatics Eger, Hungary, January 28 31, 2007 Vol 2 pp 301 308 On the correctness of template metaprograms Ádám Sipos, István Zólyomi, Zoltán

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

Adding attribute reflection to C++.

Adding attribute reflection to C++. Document Number: N3984 Date: 2014-05-07 Project: SG7 - Reflection Reply to: Cleiton Santoia Silva Daniel Auresco Adding attribute reflection to C++. Contents

More information

C++ Programming Lecture 7 Software Engineering Group

C++ Programming Lecture 7 Software Engineering Group C++ Programming Lecture 7 Software Engineering Group Philipp D. Schubert Contents 1. Template metaprogramming 2. Variadic template arguments 3. Smart pointer Template metaprogramming Template metaprogramming

More information

and the Unified Universe

and the Unified Universe Herb Sutter 2 Bja rne and the Unified Universe The C++ type system is unified! CORBA interface dynamic any variant property iterator/ range container COM class traits type flag enum enum class functor/

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

Programming at Compile Time. Rainer Grimm Training, Coaching, and Technology Consulting

Programming at Compile Time. Rainer Grimm Training, Coaching, and Technology Consulting Programming at Compile Time Rainer Grimm Training, Coaching, and Technology Consulting www.modernescpp.de Overview Constant expressions Type-traits library Template metaprogramming Template Metaprogramming

More information

The C++ Programming Language, Core Working Group. Title: Unary Folds and Empty Parameter Packs (revision 1)

The C++ Programming Language, Core Working Group. Title: Unary Folds and Empty Parameter Packs (revision 1) 1 Document number: P0036 Date: 2015-09-10 Project: The C++ Programming Language, Core Working Group Title: Unary Folds and Empty Parameter Packs (revision 1) Revises: N4358 Reply-to: Thibaut Le Jehan lejehan.thibaut@gmail.com

More information

An Introduction to Template Metaprogramming

An Introduction to Template Metaprogramming An Introduction to Template Metaprogramming Barney Dellar Software Team Lead Toshiba Medical Visualisation Systems Caveat I decided to do this talk after getting thoroughly lost on the recent talk on SFINAE.

More information

C++14 Reflections Without Macros, Markup nor External Tooling

C++14 Reflections Without Macros, Markup nor External Tooling C++14 Reflections Without Macros, Markup nor External Tooling Metaprogramming Tricks for POD Types Antony Polukhin Boost libraries maintainer (DLL, LexicalCast, Any, TypeIndex, Conversion) + Boost.CircularBuffer,

More information

Introduction to Standard C++

Introduction to Standard C++ Introduction to Standard C++ Lecture 04: Template Functions and Template Classes Massimiliano Culpo 1 1 CINECA - SuperComputing Applications and Innovation Department 07.04.2014 M.Culpo (CINECA) Introduction

More information

An Oddysey in C++ A Guided Tour of Modern C++ Per Karlström Upplysningen

An Oddysey in C++ A Guided Tour of Modern C++ Per Karlström Upplysningen An Oddysey in C++ A Guided Tour of Modern C++ Per Karlström per@karlstrom.se Upplysningen 2010-03-02 From C to C++ Bjarne Stroustrup Father of C++ 1979: Development starts 1998: ISO/IEC 14882:1998 2003:

More information

Lecture 2 Polymorphism, Traits, Policies, and Inheritance

Lecture 2 Polymorphism, Traits, Policies, and Inheritance Lecture 2 Polymorphism, Traits, Policies, and Inheritance Kenny Erleben Department of Computer Science University of Copenhagen c K. Erleben, May 4, 2006 p. 1/36 Polymorphism 1 Traditional, define abstract

More information

C++ Programming Lecture 7 Software Engineering Group

C++ Programming Lecture 7 Software Engineering Group C++ Programming Lecture 7 Software Engineering Group Philipp D. Schubert Contents 1. Template metaprogramming 2. Variadic template arguments 3. Smart pointer Template metaprogramming Template metaprogramming

More information

Modern and Lucid C++ Advanced for Professional Programmers. Part 7 Compile-Time Computation. Department I - C Plus Plus

Modern and Lucid C++ Advanced for Professional Programmers. Part 7 Compile-Time Computation. Department I - C Plus Plus Department I - C Plus Plus Modern and Lucid C++ Advanced for Professional Programmers Part 7 Compile-Time Computation Thomas Corbat / Prof. Peter Sommerlad Rapperswil, 23.02.2017 HS2017 Topics 2 SFINAE

More information

Technical Specification: Concepts

Technical Specification: Concepts Document Number: Date: 2014-02-14 Reply to: Andrew Sutton University of Akron asutton@uakron.edu Technical Specification: Concepts Note: this is an early draft. It s known to be incomplet and incorrekt,

More information

P1267R0: Custom Constraint Diagnostics

P1267R0: Custom Constraint Diagnostics P1267R0: Custom Constraint Diagnostics ISO/IEC JTC1 SC22/WG21 - Programming Languages - C++ Authors: Hana Dusíková < hana.dusikova@avast.com > Bryce Adelstein Lelbach < brycelelbach@gmail.com > Audience:

More information

C++ Template Meta. A basic introduction to basic C++ techniques used in template metaprogramming.

C++ Template Meta. A basic introduction to basic C++ techniques used in template metaprogramming. C++ Template Meta A basic introduction to basic C++ techniques used in template metaprogramming. Github Repo The presentation and all of the code are online on github, with an OSI license. github.com/zwimer/template-meta-tutorial

More information

Class Types in Non-Type Template Parameters

Class Types in Non-Type Template Parameters Class Types in Non-Type Template Parameters Document #: P0732R0 Date: 2018-02-11 Project: Programming Language C++ Audience: Evolution Reply-to: Jeff Snyder 1 TL;DR We should

More information

C++14 (Preview) Alisdair Meredith, Library Working Group Chair. Thursday, July 25, 13

C++14 (Preview) Alisdair Meredith, Library Working Group Chair. Thursday, July 25, 13 C++14 (Preview) Alisdair Meredith, Library Working Group Chair 1 1 A Quick Tour of the Sausage Factory A Committee convened under ISO/IEC so multiple companies can co-operate and define the language Google

More information

C++1z: Concepts-Lite !!! !!! !!!! Advanced Developer Conference C slides:

C++1z: Concepts-Lite !!! !!! !!!! Advanced Developer Conference C slides: C++1z: Concepts-Lite Advanced Developer Conference C++ 2014 slides: http://wiki.hsr.ch/petersommerlad/ Prof. Peter Sommerlad Director IFS Institute for Software Peter Sommerlad peter.sommerlad@hsr.ch Credo:

More information

Variant: a type-safe union without undefined behavior (v2).

Variant: a type-safe union without undefined behavior (v2). Variant: a type-safe union without undefined behavior (v2). P0087R0, ISO/IEC JTC1 SC22 WG21 Axel Naumann (axel@cern.ch), 2015-09-28 Contents Introduction 3 Version control 4 Discussion 4 Empty state and

More information

An introduction to. Templates. Generic Programming. Good old C. Metaprogramming 4/13/2017

An introduction to. Templates. Generic Programming. Good old C. Metaprogramming 4/13/2017 An introduction to C++ Templates For : COP 3330. Object oriented Programming (Using C++) http://www.compgeom.com/~piyush/teach/3330 Templates Are C macros on Steroids Give you the power to parametrize

More information

Deducing the type of variable from its initializer expression (revision 3)

Deducing the type of variable from its initializer expression (revision 3) Deducing the type of variable from its initializer expression (revision 3) Programming Language C++ Document no: N1894=05-0154 Jaakko Järvi Texas A&M University College Station, TX jarvi@cs.tamu.edu Bjarne

More information

Cpt S 122 Data Structures. Templates

Cpt S 122 Data Structures. Templates Cpt S 122 Data Structures Templates Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Introduction Function Template Function-template and function-template

More information

boost::enable_if Deep Down Boostimagical Fun Christian Bay and Kasper A Andersen Department of Computer Science University of Copenhagen

boost::enable_if Deep Down Boostimagical Fun Christian Bay and Kasper A Andersen Department of Computer Science University of Copenhagen Deep Down Boostimagical Fun boost::enable_if Christian Bay and Kasper A Andersen Department of Computer Science University of Copenhagen C. Bay and K. A. Andersen, June 2, 2006 p. 1/12 SFINAE revisited

More information

Part XI. Algorithms and Templates. Philip Blakely (LSC) C++ Introduction 314 / 370

Part XI. Algorithms and Templates. Philip Blakely (LSC) C++ Introduction 314 / 370 Part XI Algorithms and Templates Philip Blakely (LSC) C++ Introduction 314 / 370 STL Algorithms Outline 44 STL Algorithms 45 Templates 46 Summing an array 47 Templated classes Philip Blakely (LSC) C++

More information

Variadic Templates: Exploring the Design Space

Variadic Templates: Exploring the Design Space Variadic Templates: Exploring the Design Space Douglas Gregor Jaakko Järvi Gary Powell Document number: N1704=04-0144 Revises document number: N1603=04-0043 Date: September 10, 2004 Project: Programming

More information

Red Code / Green Code: Generalizing const

Red Code / Green Code: Generalizing const Red Code / Green Code: Generalizing const (2/3rds of a Proof of Concept) Scott Meyers, Ph.D. Software Development Consultant smeyers@aristeia.com Voice: 503/638 6028 Fax: 503/638 6614 Last Revised: 5/7/07

More information

Deducing the type of variable from its initializer expression (revision 4)

Deducing the type of variable from its initializer expression (revision 4) Deducing the type of variable from its initializer expression (revision 4) Programming Language C++ Document no: N1984=06-0054 Jaakko Järvi Texas A&M University College Station, TX jarvi@cs.tamu.edu Bjarne

More information

Francesco Nidito. Programmazione Avanzata AA 2005/06

Francesco Nidito. Programmazione Avanzata AA 2005/06 Francesco Nidito Programmazione Avanzata AA 2005/06 Outline 1 2 3 4 5 Reference: K. Czarnecki, U. W. Eisenecker, Generative : Methods, Tools, and Applications, Chapter 10 What Is? At this moment is quite

More information

Making New Pseudo-Languages with C++

Making New Pseudo-Languages with C++ Making New Pseudo-Languages with C++ Build You a C++ For Great Good ++ A 10,000 Metre Talk by David Williams-King Agenda 1/4 Introduction 2/4 Polymorphism & Multimethods 3/4 Changing the Behaviour of C++

More information

MODERN AND LUCID C++ ADVANCED

MODERN AND LUCID C++ ADVANCED Informatik MODERN AND LUCID C++ ADVANCED for Professional Programmers Prof. Peter Sommerlad Thomas Corbat Director of IFS Research Assistant Rapperswil, FS 2016 LIBRARY API/ABI DESIGN PIMPL IDIOM HOURGLASS

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

Implicit Evaluation of auto Variables and Arguments

Implicit Evaluation of auto Variables and Arguments Implicit Evaluation of auto Variables and Arguments Document number: N4035 (update of N3748) Authors: Joël Falcou University Paris XI, LRI Peter Gottschling SimuNova Herb Sutter Microsoft Date: 2013-08-30

More information

Class Types in Non-Type Template Parameters

Class Types in Non-Type Template Parameters Class Types in Non-Type Template Parameters Document #: P0732R2 Date: 2018-06-06 Project: Programming Language C++ Audience: Evolution Reply-to: Jeff Snyder Louis Dionne

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

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

Templates. Zoltán Porkoláb: C++11/14 1 Templates From macros to templates Parameter deduction, instantiation,specialization Class templates, partial specialization Explicit instantiation Dependent types Scope resolution, lookup Mixins CRTP

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

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

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

Modernes C++ Träume und Alpträume

Modernes C++ Träume und Alpträume Modernes Träume und Alpträume Nicolai M. Josuttis 5/17 217 by IT-communication.com 1 Independent consultant continuously learning since 1962 Nicolai M. Josuttis Systems Architect, Technical Manager finance,

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

UNIT TESTING OF C++ TEMPLATE METAPROGRAMS

UNIT TESTING OF C++ TEMPLATE METAPROGRAMS STUDIA UNIV. BABEŞ BOLYAI, INFORMATICA, Volume LV, Number 1, 2010 UNIT TESTING OF C++ TEMPLATE METAPROGRAMS ÁBEL SINKOVICS Abstract. Unit testing, a method for verifying a piece of software, is a widely

More information

New Tools for Class and Library Authors

New Tools for Class and Library Authors New Tools for Class and Library Authors By Scott Schurr for C++ Now! 2012 Topics o _Pragma o static_assert o explicit conversion operators o decltype o constexpr o variadic templates 2 _Pragma o Borrowed

More information

GridKa School 2013: Effective Analysis C++ Templates

GridKa School 2013: Effective Analysis C++ Templates GridKa School 2013: Effective Analysis C++ Templates Introduction Jörg Meyer, Steinbuch Centre for Computing, Scientific Data Management KIT University of the State of Baden-Wuerttemberg and National Research

More information

Static If Considered

Static If Considered Document number: N3613 Date: 2013-03-16 Study group: Concepts Reply to: Bjarne Stroustrup Gabriel Dos Reis Andrew Sutton Static If Considered Bjarne

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

Working Draft, C++ extensions for Concepts

Working Draft, C++ extensions for Concepts Document Number: Date: 2017-06-19 Revises: N4641 Reply to: Andrew Sutton University of Akron asutton@uakron.edu Working Draft, C++ extensions for Concepts Note: this is an early draft. It s known to be

More information

Object-Oriented Programming for Scientific Computing

Object-Oriented Programming for Scientific Computing Object-Oriented Programming for Scientific Computing Traits and Policies Ole Klein Interdisciplinary Center for Scientific Computing Heidelberg University ole.klein@iwr.uni-heidelberg.de Summer Semester

More information

Modern C++ Interfaces

Modern C++ Interfaces Modern C++ Interfaces Complexity, Emergent Simplicity, SFINAE, and Second Order Properties of Types Stephen C. Dewhurst stevedewhurst.com 1 About Steve Dewhurst Steve Dewhurst is the cofounder and president

More information

Deducing the type of variable from its initializer expression Programming Language C++ Document no: N1721=

Deducing the type of variable from its initializer expression Programming Language C++ Document no: N1721= Deducing the type of variable from its initializer expression Programming Language C++ Document no: N1721=04-0161 Jaakko Järvi Texas A&M University College Station, TX jarvi@cs.tamu.edu Bjarne Stroustrup

More information

Proposed Wording for Variadic Templates (Revision 1)

Proposed Wording for Variadic Templates (Revision 1) Proposed Wording for Variadic Templates (Revision 1) Authors: Douglas Gregor, Indiana University Jaakko Järvi, Texas A&M University Jens Maurer Jason Merrill, Red Hat Document number: N2191=07-0051 Revises

More information

C++14 and Concepts. Bjarne Stroustrup. Texas A&M University

C++14 and Concepts. Bjarne Stroustrup. Texas A&M University C++14 and Concepts Bjarne Stroustrup Texas A&M University www.stroustrup.com Videos Broad spectrum C++ talks The Essence of C++: With Examples in C++84, C++98, C++11, and C++14:. http://channel9.msdn.com/events/goingnative/2013

More information

Proposed Wording for Variadic Templates

Proposed Wording for Variadic Templates Proposed Wording for Variadic Templates Authors: Douglas Gregor, Indiana University Jaakko Järvi, Texas A&M University Jens Maurer Jason Merrill, Red Hat Document number: N2152=07-0012 Revises document

More information

CSE 307: Principles of Programming Languages

CSE 307: Principles of Programming Languages CSE 307: Principles of Programming Languages Variables and Constants R. Sekar 1 / 22 Topics 2 / 22 Variables and Constants Variables are stored in memory, whereas constants need not be. Value of variables

More information

Template metaprogramming techniques for concept-based specialization

Template metaprogramming techniques for concept-based specialization Scientific Programming 21 (2013) 43 61 43 DOI 10.3233/SPR-130362 IOS Press Template metaprogramming techniques for concept-based specialization Bruno Bachelet a,b,, Antoine Mahul c and Loïc Yon a,b a Clermont

More information

Part III. Advanced C ++

Part III. Advanced C ++ Part III Advanced C ++ topics Philip Blakely (LSC) Advanced C++ 66 / 119 References The following are highly regarded books. They are fairly in-depth, and I haven t read them in their entirity. However,

More information

C++ Template Metaprogramming

C++ Template Metaprogramming C++ Template Metaprogramming Juan Pedro Bolívar Puente Ableton AG 16 May 2013 Agenda 1 Introduction 2 Concepts and techniques 3 Reasoning about metaprograms 4 Conclusions Agenda 1 Introduction 2 Concepts

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

Fixing Atomic Initialization, Rev1

Fixing Atomic Initialization, Rev1 Project: ISO JTC1/SC22/WG21: Programming Language C++ Doc No: WG21 P0883R1 Date: 2018-06-05 Reply to: Nicolai Josuttis (nico@josuttis.de) Audience: SG1, LEWG, LWG Prev. Version: P0883R0 Fixing Atomic Initialization,

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

Part II. C continued. Philip Blakely (LSC) Advanced C++ 35 / 119

Part II. C continued. Philip Blakely (LSC) Advanced C++ 35 / 119 Part II C ++ 11 continued Philip Blakely (LSC) Advanced C++ 35 / 119 Delegated constructor In C ++ 03, if there is common code between constructors, you have to create an init() or similar function: class

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

Proposed Wording for Concurrent Data Structures: Hazard Pointer and Read Copy Update (RCU)

Proposed Wording for Concurrent Data Structures: Hazard Pointer and Read Copy Update (RCU) Document number: D0566R1 Date: 20170619 (pre Toronto) Project: Programming Language C++, WG21, SG1,SG14, LEWG, LWG Authors: Michael Wong, Maged M. Michael, Paul McKenney, Geoffrey Romer, Andrew Hunter

More information

CS93SI Handout 04 Spring 2006 Apr Review Answers

CS93SI Handout 04 Spring 2006 Apr Review Answers CS93SI Handout 04 Spring 2006 Apr 6 2006 Review Answers I promised answers to these questions, so here they are. I'll probably readdress the most important of these over and over again, so it's not terribly

More information

Proposing Standard Library Support for the C++ Detection Idiom, v2

Proposing Standard Library Support for the C++ Detection Idiom, v2 Proposing Standard Library Support for the C++ Detection Idiom, v2 Document #: WG21 N4502 Date: 2015-05-03 Revises: N4436 Project: JTC1.22.32 Programming Language C++ Reply to: Walter E. Brown

More information

MetaProgramming. Programming from above. Python. C++ (Template MetaProgramming TMP)

MetaProgramming. Programming from above. Python. C++ (Template MetaProgramming TMP) MetaProgramming Programming from above Python C++ (Template MetaProgramming TMP) Python (based on David Beazley @dabeaz) Debugging with Print A function def add(x, y): return x + y A function with debugging

More information

Class Types in Non-Type Template Parameters

Class Types in Non-Type Template Parameters Class Types in Non-Type Template Parameters Document #: D0732R1 Date: 2018-03-30 Project: Programming Language C++ Audience: Evolution Reply-to: Jeff Snyder Louis Dionne

More information

Static reflection (revision 4)

Static reflection (revision 4) Document number: P0194R0 Date: 2016-02-08 Project: Programming Language C++ Audience: Reflection (SG7) / EWG Reply-to: Matúš Chochlík(chochlik@gmail.com), Axel Naumann (Axel.Naumann@cern.ch) Static reflection

More information

Metaclasses: Generative C++

Metaclasses: Generative C++ Metaclasses: Generative C++ Document Number: P0707 R3 Date: 2018-02-11 Reply-to: Herb Sutter (hsutter@microsoft.com) Audience: SG7, EWG Contents 1 Overview...2 2 Language: Metaclasses...7 3 Library: Example

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++ Template Instantiation and Concepts in CLANG

C++ Template Instantiation and Concepts in CLANG Seminar Program Analysis and Transformation HSR, University of Applied Sciences Rapperswil C++ Template Instantiation and Concepts in CLANG Yves Thrier, ythrier(at)hsr.ch June 3, 2011 Abstract In modern

More information

C++ Metastring Library

C++ Metastring Library C++ Metastring Library Zalán Szűgyi, Ábel Sinkovics, Norbert Pataki, and Zoltán Porkoláb Department of Programming Languages and Compilers, Eötvös Loránd University Pázmány Péter sétány 1/C H-1117 Budapest,

More information

Explicit Conversion Operator Draft Working Paper

Explicit Conversion Operator Draft Working Paper Explicit Conversion Operator Draft Working Paper Lois Goldthwaite, Michael Wong IBM michaelw@ca.ibm.com ACCU Lois@LoisGoldthwaite.com Document number: N2223=07-0083 Date: 2007-03-11 Project: Programming

More information

Working Draft, C++ Extensions for Concepts

Working Draft, C++ Extensions for Concepts ISO 04 All rights reserved Document Number: N405 Date: 04-0-0 Revises: N4040 Editor: Andrew Sutton University of Akron asutton@uakron.edu Working Draft, C++ Extensions for Concepts Note: this is an early

More information

C++17 and Beyond. Mark Isaacson

C++17 and Beyond. Mark Isaacson C++17 and Beyond Mark Isaacson 1 Roadmap What s coming in C++17 and C++20 The surprising utility of std::string_view C++20 s most deliciously scary feature: operator dot Making templates more accessible

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

Decltype (revision 6): proposed wording

Decltype (revision 6): proposed wording Decltype (revision 6): proposed wording Programming Language C++ Document no: N2115=06-0185 Jaakko Järvi Texas A&M University College Station, TX jarvi@cs.tamu.edu Bjarne Stroustrup AT&T Research and Texas

More information

Structuur van Computerprogramma s 2

Structuur van Computerprogramma s 2 Structuur van Computerprogramma s 2 dr. Dirk Deridder Dirk.Deridder@vub.ac.be http://soft.vub.ac.be/ Vrije Universiteit Brussel - Faculty of Science and Bio-Engineering Sciences - Computer Science Department

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

Variadic functions: Variadic templates or initializer lists? -- Revision 1

Variadic functions: Variadic templates or initializer lists? -- Revision 1 Variadic functions: Variadic templates or initializer lists? -- Revision 1 Author: Loïc Joly (loic.actarus.joly@numericable.fr ) Document number: N2772=08-0282 Date: 2008-09-17 Project: Programming Language

More information

Variant: a type-safe union that is rarely invalid (v5).

Variant: a type-safe union that is rarely invalid (v5). Variant: a type-safe union that is rarely invalid (v5). P0088R0, ISO/IEC JTC1 SC22 WG21 Axel Naumann (axel@cern.ch), 2015-09-27 Contents Introduction 4 Results of the LEWG review in Urbana.................

More information