bsi standards publication · 2021. 2. 22. · this british standard is the uk implementation of...

15
BSI Standards Publication Programming languages — C++ BS ISO/IEC 14882:2020 This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Upload: others

Post on 22-Jun-2021

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

BSI Standards Publication

Programming languages — C++

BS ISO/IEC 14882:2020This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 2: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

Programming languages — C++Langages de programmation — C++

© ISO/IEC 2020

INTERNATIONAL STANDARD

ISO/IEC14882

Reference numberISO/IEC 14882:2020(E)

Sixth edition2020-12

National foreword

This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn.

The UK participation in its preparation was entrusted to Technical Committee IST/5, Programming languages, their environments and system software interfaces.

A list of organizations represented on this committee can be obtained on request to its committee manager.

This publication does not purport to include all the necessary provisions of a contract. Users are responsible for its correct application.

© The British Standards Institution 2020 Published by BSI Standards Limited 2020

ISBN 978 0 539 06199 4

ICS 35.060

Compliance with a British Standard cannot confer immunity from legal obligations.

This British Standard was published under the authority of the Standards Policy and Strategy Committee on 31 December 2020.

Amendments/corrigenda issued since publication

Date Text affected

BRITISH STANDARDBS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 3: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

Programming languages — C++Langages de programmation — C++

© ISO/IEC 2020

INTERNATIONAL STANDARD

ISO/IEC14882

Reference numberISO/IEC 14882:2020(E)

Sixth edition2020-12

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 4: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

ii © ISO/IEC 2020 – All rights reserved

COPYRIGHT PROTECTED DOCUMENT

© ISO/IEC 2020All rights reserved. Unless otherwise specified, or required in the context of its implementation, no part of this publication may be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting on the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address below or ISO’s member body in the country of the requester.

ISO copyright officeCP 401 • Ch. de Blandonnet 8CH-1214 Vernier, GenevaPhone: +41 22 749 01 11Email: [email protected]: www.iso.org

Published in Switzerland

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 5: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

ContentsForeword x

1 Scope 1

2 Normative references 2

3 Terms and definitions 3

4 General principles 94.1 Implementation compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.2 Structure of this document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.3 Syntax notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

5 Lexical conventions 125.1 Separate translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125.2 Phases of translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125.3 Character sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.4 Preprocessing tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145.5 Alternative tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155.6 Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155.7 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155.8 Header names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165.9 Preprocessing numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165.10 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165.11 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175.12 Operators and punctuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185.13 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

6 Basics 286.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286.2 Declarations and definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286.3 One-definition rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306.4 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346.5 Name lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406.6 Program and linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536.7 Memory and objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576.8 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716.9 Program execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

7 Expressions 907.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907.2 Properties of expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917.3 Standard conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 947.4 Usual arithmetic conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997.5 Primary expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997.6 Compound expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1167.7 Constant expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

8 Statements 1538.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1538.2 Labeled statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1548.3 Expression statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1548.4 Compound statement or block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1548.5 Selection statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

Contents © ISO/IEC 2020 – All rights reserved iii

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 6: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

8.6 Iteration statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1568.7 Jump statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1598.8 Declaration statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1618.9 Ambiguity resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

9 Declarations 1639.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1639.2 Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1659.3 Declarators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1829.4 Initializers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1979.5 Function definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2139.6 Structured binding declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2199.7 Enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2209.8 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2249.9 The using declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2319.10 The asm declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2369.11 Linkage specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2379.12 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

10 Modules 24710.1 Module units and purviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24710.2 Export declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24810.3 Import declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25110.4 Global module fragment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25210.5 Private module fragment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25410.6 Instantiation context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25510.7 Reachability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

11 Classes 25811.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25811.2 Properties of classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25911.3 Class names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26011.4 Class members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26211.5 Unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28411.6 Local class declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28711.7 Derived classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28711.8 Member name lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29511.9 Member access control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29811.10 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30811.11 Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31911.12 Free store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

12 Overloading 32412.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32412.2 Overloadable declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32412.3 Declaration matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32612.4 Overload resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32712.5 Address of overloaded function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35112.6 Overloaded operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35212.7 Built-in operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35612.8 User-defined literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358

13 Templates 36013.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36013.2 Template parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36113.3 Names of template specializations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36513.4 Template arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36813.5 Template constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37313.6 Type equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

Contents © ISO/IEC 2020 – All rights reserved iv

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 7: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

13.7 Template declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38013.8 Name resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40113.9 Template instantiation and specialization . . . . . . . . . . . . . . . . . . . . . . . . . . . 41713.10 Function template specializations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431

14 Exception handling 45114.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45114.2 Throwing an exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45214.3 Constructors and destructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45314.4 Handling an exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45414.5 Exception specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45614.6 Special functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458

15 Preprocessing directives 46015.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46015.2 Conditional inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46215.3 Source file inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46415.4 Module directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46515.5 Header unit importation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46615.6 Macro replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46715.7 Line control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47215.8 Error directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47315.9 Pragma directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47315.10 Null directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47315.11 Predefined macro names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47315.12 Pragma operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

16 Library introduction 47716.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47716.2 The C standard library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47816.3 Method of description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47816.4 Library-wide requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484

17 Language support library 50517.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50517.2 Common definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50517.3 Implementation properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50917.4 Integer types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51917.5 Startup and termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52017.6 Dynamic memory management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52217.7 Type identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52917.8 Source location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53017.9 Exception handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53217.10 Initializer lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53617.11 Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53717.12 Coroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54517.13 Other runtime support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549

18 Concepts library 55218.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55218.2 Equality preservation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55218.3 Header <concepts> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55318.4 Language-related concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55518.5 Comparison concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56018.6 Object concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56318.7 Callable concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563

Contents © ISO/IEC 2020 – All rights reserved v

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 8: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

19 Diagnostics library 56519.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56519.2 Exception classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56519.3 Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56819.4 Error numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56819.5 System error support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570

20 General utilities library 57920.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57920.2 Utility components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57920.3 Compile-time integer sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58420.4 Pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58520.5 Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58920.6 Optional objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59920.7 Variants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61120.8 Storage for any type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62220.9 Bitsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62720.10 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63220.11 Smart pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64820.12 Memory resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67120.13 Class template scoped_allocator_adaptor . . . . . . . . . . . . . . . . . . . . . . . . . . 68020.14 Function objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68420.15 Metaprogramming and type traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70720.16 Compile-time rational arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73220.17 Class type_index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73420.18 Execution policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73620.19 Primitive numeric conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73820.20 Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740

21 Strings library 75921.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75921.2 Character traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75921.3 String classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76421.4 String view classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79021.5 Null-terminated sequence utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 800

22 Containers library 80522.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80522.2 Container requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80522.3 Sequence containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83922.4 Associative containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86722.5 Unordered associative containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88522.6 Container adaptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90622.7 Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914

23 Iterators library 92123.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92123.2 Header <iterator> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92123.3 Iterator requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92823.4 Iterator primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94823.5 Iterator adaptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95123.6 Stream iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97223.7 Range access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 978

24 Ranges library 98024.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98024.2 Header <ranges> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98024.3 Range access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98524.4 Range requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 989

Contents © ISO/IEC 2020 – All rights reserved vi

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 9: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

24.5 Range utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99224.6 Range factories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99724.7 Range adaptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1007

25 Algorithms library 104425.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104425.2 Algorithms requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104425.3 Parallel algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104625.4 Header <algorithm> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104925.5 Algorithm result types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108425.6 Non-modifying sequence operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108725.7 Mutating sequence operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109925.8 Sorting and related operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111525.9 Header <numeric> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114225.10 Generalized numeric operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114525.11 Specialized <memory> algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115425.12 C library algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1160

26 Numerics library 116126.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116126.2 Numeric type requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116126.3 The floating-point environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116126.4 Complex numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116226.5 Bit manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117026.6 Random number generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117326.7 Numeric arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121026.8 Mathematical functions for floating-point types . . . . . . . . . . . . . . . . . . . . . . . . 122926.9 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1244

27 Time library 124527.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124527.2 Header <chrono> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124527.3 Cpp17Clock requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125927.4 Time-related traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125927.5 Class template duration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126127.6 Class template time_point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126827.7 Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127127.8 The civil calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128227.9 Class template hh_mm_ss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131127.10 12/24 hours functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131327.11 Time zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131327.12 Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132627.13 Parsing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133027.14 Header <ctime> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1334

28 Localization library 133528.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133528.2 Header <locale> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133528.3 Locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133628.4 Standard locale categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134228.5 C library locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1374

29 Input/output library 137529.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137529.2 Iostreams requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137529.3 Forward declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137629.4 Standard iostream objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137829.5 Iostreams base classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138029.6 Stream buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1395

Contents © ISO/IEC 2020 – All rights reserved vii

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 10: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

29.7 Formatting and manipulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140329.8 String-based streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142729.9 File-based streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144129.10 Synchronized output streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145329.11 File systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145829.12 C library files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1503

30 Regular expressions library 150630.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150630.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150630.3 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150730.4 Header <regex> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150830.5 Namespace std::regex_constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151230.6 Class regex_error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151530.7 Class template regex_traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151530.8 Class template basic_regex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151730.9 Class template sub_match . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152230.10 Class template match_results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152330.11 Regular expression algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152830.12 Regular expression iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153230.13 Modified ECMAScript regular expression grammar . . . . . . . . . . . . . . . . . . . . . . 1537

31 Atomic operations library 154031.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154031.2 Header <atomic> synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154031.3 Type aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154431.4 Order and consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154431.5 Lock-free property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154631.6 Waiting and notifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154631.7 Class template atomic_ref . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154731.8 Class template atomic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155331.9 Non-member functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156831.10 Flag type and operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156831.11 Fences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1570

32 Thread support library 157232.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157232.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157232.3 Stop tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157432.4 Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157932.5 Mutual exclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158632.6 Condition variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160532.7 Semaphore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161232.8 Coordination types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161432.9 Futures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1617

Annex A Grammar summary 1632A.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1632A.2 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1632A.3 Lexical conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1632A.4 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1636A.5 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1637A.6 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1641A.7 Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1641A.8 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1647A.9 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1648A.10 Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1649A.11 Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1649A.12 Exception handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1651

Contents © ISO/IEC 2020 – All rights reserved viii

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 11: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

A.13 Preprocessing directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1651

Annex B Implementation quantities 1653

Annex C Compatibility 1655C.1 C++ and ISO C++ 2017 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1655C.2 C++ and ISO C++ 2014 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1662C.3 C++ and ISO C++ 2011 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1666C.4 C++ and ISO C++ 2003 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1667C.5 C++ and ISO C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1673C.6 C standard library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1681

Annex D Compatibility features 1683D.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1683D.2 Arithmetic conversion on enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1683D.3 Implicit capture of *this by reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1683D.4 Comma operator in subscript expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 1683D.5 Array comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1683D.6 Deprecated volatile types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1684D.7 Redeclaration of static constexpr data members . . . . . . . . . . . . . . . . . . . . . . 1684D.8 Non-local use of TU-local entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1685D.9 Implicit declaration of copy functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1685D.10 C headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1685D.11 Requires paragraph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1686D.12 Relational operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1686D.13 char* streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1687D.14 Deprecated type traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1694D.15 Tuple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1695D.16 Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1695D.17 Deprecated iterator class template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1696D.18 Deprecated move_iterator access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1696D.19 Deprecated shared_ptr atomic access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1696D.20 Deprecated basic_string capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1698D.21 Deprecated standard code conversion facets . . . . . . . . . . . . . . . . . . . . . . . . . . 1698D.22 Deprecated convenience conversion interfaces . . . . . . . . . . . . . . . . . . . . . . . . . 1700D.23 Deprecated locale category facets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1703D.24 Deprecated filesystem path factory functions . . . . . . . . . . . . . . . . . . . . . . . . . . 1704D.25 Deprecated atomic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1704

Bibliography 1706

Cross references 1707

Cross references from ISO C++ 2017 1731

Index 1734

Index of grammar productions 1768

Index of library headers 1773

Index of library names 1775

Index of library concepts 1847

Index of implementation-defined behavior 1850

Contents © ISO/IEC 2020 – All rights reserved ix

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 12: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

ForewordISO (the International Organization for Standardization) and IEC (the International ElectrotechnicalCommission) form the specialized system for worldwide standardization. National bodies that are membersof ISO or IEC participate in the development of International Standards through technical committeesestablished by the respective organization to deal with particular fields of technical activity. ISO and IECtechnical committees collaborate in fields of mutual interest. Other international organizations, governmentaland non-governmental, in liaison with ISO and IEC, also take part in the work.The procedures used to develop this document and those intended for its further maintenance are described inthe ISO/IEC Directives, Part 1. In particular the different approval criteria needed for the different types ofdocument should be noted. This document was drafted in accordance with the editorial rules of the ISO/IECDirectives, Part 2 (see www.iso.org/directives).Attention is drawn to the possibility that some of the elements of this document may be the subject of patentrights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. Details of anypatent rights identified during the development of the document will be in the Introduction and/or on theISO list of patent declarations received (see www.iso.org/patents) or the IEC list of patent declarationsreceived (see http://patents.iec.ch).Any trade name used in this document is information given for the convenience of users and does notconstitute an endorsement.For an explanation on the voluntary nature of standards, the meaning of ISO specific terms and expressions re-lated to conformity assessment, as well as information about ISO’s adherence to the World Trade Organization(WTO) principles in the Technical Barriers to Trade (TBT), see www.iso.org/iso/foreword.html.This document was prepared by Joint Technical Committee ISO/IEC JTC 1, Information technology,Subcommittee SC 22, Programming languages, their environments and system software interfaces.This sixth edition cancels and replaces the fifth edition (ISO/IEC 14882:2017), which has been technicallyrevised.The main changes compared to the previous edition are as follows:

— inclusion of the provisions of ISO/IEC TS 19217:2015, ISO/IEC TS 21425:2017, ISO/IEC TS 22277:2017,ISO/IEC TS 21544:2018, portions of ISO/IEC TS 19571:2016, and portions of ISO/IEC TS 19568:2017.

— addition of concepts, requires-clauses, requires-expressions, and <concepts> (18.3) header— addition of coroutines, including co_yield, co_await, and co_return keywords and <coroutine>

(17.12.2) header— addition of modules, import-declarations, and export-declarations— addition of three-way comparison, defaulted comparisons, rewriting of comparison operator expressions,

and <compare> (17.11.1) header— addition of designated initializers— support for class types and floating-point types as the type of a non-type template parameter— new attributes [[no_unique_address]], [[likely]], [[unlikely]]— support for optional reason string in [[nodiscard]] attribute— ability to require constant initialization with constinit keyword— ability to require constant evaluation with consteval keyword— extensions to constant evaluation— support for controlling destruction in a class-specific operator delete function— addition of using enum declaration— addition of char8_t type— support for an initializer statement in range-based for loops

Foreword © ISO/IEC 2020 – All rights reserved x

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 13: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

— support for default member initializers for bit-fields— support for parenthesized aggregate initialization— extensions to lambda expressions— extensions to structured bindings— support for inline namespaces in nested namespace definitions— support for conditionally-explicit member functions— extensions to class template argument deduction— reduced cases in which typename is required— support for calling an undeclared template-id via argument-dependent name lookup— revised memory model— extended support for variadic macros with __VA_OPT__— feature test macros and <version> (17.3.2) header— addition of ranges and <ranges> (24.2) header— addition of calendar and time zone support— addition of text formatting library and <format> (20.20.1) header— addition of <barrier> (32.8.3.2), <latch> (32.8.2.2), and <semaphore> (32.7.2) headers— addition of mathematical constants library and <numbers> (26.9.1) header— support for representing source locations and <source_location> (17.8.1) header— addition of span view and <span> (22.7.2) header— addition of joining thread class and <stop_token> (32.3.2) header— extensions to atomic types and operations— addition of unsequenced execution policy— new utility functions, types, and templates in the standard library— addition of bit manipulation library and <bit> (26.5.2) header— addition of a synchronized buffered output stream and <syncstream> (29.10.1) header— support for heterogeneous lookup for unordered containers— support for element existence detection in associative containers— support for move semantics in <numeric> (25.9) algorithms— support for efficient access to the buffer of a basic_stringbuf— extended constant expression evaluation support in the standard library

Any feedback or questions on this document should be directed to the user’s national standards body. Acomplete listing of these bodies can be found at www.iso.org/members.html.

Foreword © ISO/IEC 2020 – All rights reserved xi

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 14: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.

Page 15: BSI Standards Publication · 2021. 2. 22. · This British Standard is the UK implementation of ISO/IEC 14882:2020. It supersedes BS ISO/IEC 14882:2017, which is withdrawn. The UK

ISO/IEC 14882:2020(E)

1 Scope [intro.scope]1 This document specifies requirements for implementations of the C++ programming language. The first such

requirement is that they implement the language, so this document also defines C++. Other requirementsand relaxations of the first requirement appear at various places within this document.

2 C++ is a general purpose programming language based on the C programming language as described inISO/IEC 9899:2018 Programming languages — C (hereinafter referred to as the C standard). C++ providesmany facilities beyond those provided by C, including additional data types, classes, templates, exceptions,namespaces, operator overloading, function name overloading, references, free store management operators,and additional library facilities.

Scope © ISO/IEC 2020 – All rights reserved 1

BS ISO/IEC 14882:2020

This is a preview of "BS ISO/IEC 14882:202...". Click here to purchase the full version from the ANSI store.