Programming Languages — C++ Extensions for Library Fundamentals

ISO/IEC TS 19568:2017 describes extensions to the C++ Standard Library (1.2). These extensions are classes and functions that are likely to be used widely within a program and/or on the interface boundaries between libraries written by different organizations. ISO/IEC TS 19568:2017 is non-normative. Some of the library components in this technical specification may be considered for standardization in a future version of C++, but they are not currently part of any C++ standard. Some of the components in this technical specification may never be standardized, and others may be standardized in a substantially changed form. The goal of this technical specification is to build more widespread existing practice for an expanded C++ standard library. It gives advice on extensions to those vendors who wish to provide them.

Langages de programmation — Extensions C++ pour la bibliothèque fondamentaux

General Information

Status
Published
Publication Date
29-Mar-2017
Current Stage
9599 - Withdrawal of International Standard
Start Date
26-Aug-2024
Completion Date
30-Oct-2025
Ref Project

Relations

Technical specification
ISO/IEC TS 19568:2017 - Programming Languages — C++ Extensions for Library Fundamentals Released:3/30/2017
English language
115 pages
sale 15% off
Preview
sale 15% off
Preview

Standards Content (Sample)


TECHNICAL ISO/IEC TS
SPECIFICATION 19568
Second edition
2017-03
Programming languages — C++
extensions for library fundamentals
Langages de programmation — Extensions C++ pour la bibliothèque
fondamentaux
Reference number
©
ISO/IEC 2017
© ISO/IEC 2017, Published in Switzerland
All rights reserved. Unless otherwise specified, 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 office
Ch. de Blandonnet 8 • CP 401
CH-1214 Vernier, Geneva, Switzerland
Tel. +41 22 749 01 11
Fax +41 22 749 09 47
copyright@iso.org
www.iso.org
ii © ISO/IEC 2017 – All rights reserved

Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .vii
1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Normative references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Namespaces, headers, and modifications to standard classes . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.4 Terms and definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 Future plans (Informative) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.6 Feature-testing recommendations (Informative) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  3
2 Modifications to the C++ Standard Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  5
2.1 Uses-allocator construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  5
3 General utilities library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 Utility components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 Class erased_type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  6
3.2.2 Calling a function with a tuple of arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  7
3.3 Metaprogramming and type traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.2 Other type transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3.3 Logical operator traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3.4 Detection idiom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.4 Compile-time rational arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5 Time utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.6 System error support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.6.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.7 Class template propagate_const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.7.1 Class template propagate_const general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.7.2 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . 16
3.7.3 propagate_const requirements on T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.7.3.1 propagate_const requirements on class type T . . . . . . . . . . . . . . . . . . . . . 18
3.7.4 propagate_const constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.7.5 propagate_const assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.7.6 propagate_const const observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.7.7 propagate_const non-const observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.7.8 propagate_const modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.7.9 propagate_const relational operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.7.10 propagate_const specialized algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.7.11 propagate_const underlying pointer access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.7.12 propagate_const hash support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.7.13 propagate_const comparison function objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4 Function objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Class template function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.2.1 function construct/copy/destroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.2.2 function modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
iii
© ISO/IEC 2017 — All rights reserved

4.3 Searchers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3.1 Class template default_searcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3.1.1 default_searcher creation functions . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3.2 Class template boyer_moore_searcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3.2.1 boyer_moore_searcher creation functions . . . . . . . . . . . . . . . . . . . . . . . 31
4.3.3 Class template boyer_moore_horspool_searcher . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.3.3.1 boyer_moore_horspool_searcher creation functions . . . . . . . . . . . . . . . . . . 32
4.4 Function template not_fn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5 Optional objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.1 In general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.2 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.3 optional for object types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.3.1 Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.3.2 Destructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.3.3 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.3.4 Swap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3.5 Observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.4 In-place construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.5 No-value state indicator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.6 Class bad_optional_access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.7 Relational operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.8 Comparison with nullopt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.9 Comparison with T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.10 Specialized algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.11 Hash support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6 Class any . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.2 Class bad_any_cast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.3 Class any . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.3.1 any construct/destruct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.3.2 any assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.3.3 any modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6.3.4 any observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6.4 Non-member functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7 string_view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.2 Class template basic_string_view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.3 basic_string_view constructors and assignment operators . . . . . . . . . . . . . . . . . . . . . . . . . 57
7.4 basic_string_view iterator support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.5 basic_string_view capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.6 basic_string_view element access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.7 basic_string_view modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.8 basic_string_view string operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.8.1 Searching basic_string_view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.9 basic_string_view non-member comparison functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.10 Inserters and extractors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.11 Hash support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
8 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
8.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
8.2 Shared-ownership pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
8.2.1 Class template shared_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
8.2.1.1 shared_ptr constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
iv
© ISO/IEC 2017 — All rights reserved

8.2.1.2 shared_ptr observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
8.2.1.3 shared_ptr casts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.2.1.4 shared_ptr hash support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.2.2 Class template weak_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.2.2.1 weak_ptr constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
8.3 Type-erased allocator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
8.4 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
8.5 Class memory_resource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.5.1 Class memory_resource overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.5.2 memory_resource public member functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
8.5.3 memory_resource protected virtual member functions . . . . . . . . . . . . . . . . . . . . . . 79
8.5.4 memory_resource equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
8.6 Class template polymorphic_allocator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
8.6.1 Class template polymorphic_allocator overview . . . . . . . . . . . . . . . . . . . . . . . . . . 80
8.6.2 polymorphic_allocator constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.6.3 polymorphic_allocator member functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8.6.4 polymorphic_allocator equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
8.7 template alias resource_adaptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
8.7.1 resource_adaptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
8.7.2 resource_adaptor_imp constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
8.7.3 resource_adaptor_imp member functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
8.8 Access to program-wide memory_resource objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
8.9 Pool resource classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
8.9.1 Classes synchronized_pool_resource and unsynchronized_pool_resource . . . . . . . . . . . . 85
8.9.2 pool_options data members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
8.9.3 pool resource constructors and destructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
8.9.4 pool resource members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
8.10 Class monotonic_buffer_resource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
8.10.1 Class monotonic_buffer_resource overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
8.10.2 monotonic_buffer_resource constructor and destructor . . . . . . . . . . . . . . . . . . . . . . 90
8.10.3 monotonic_buffer_resource members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.11 Alias templates using polymorphic memory resources . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.11.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.11.2 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
8.11.3 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
8.11.4 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
8.11.5 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  93
8.11.6 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
8.11.7 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
8.11.8 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . 94
8.11.9 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . 95
8.11.10 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
8.12 Non-owning pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
8.12.1 Class template observer_ptr overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
8.12.2 observer_ptr constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.12.3 observer_ptr observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.12.4 observer_ptr conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.12.5 observer_ptr modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.12.6 observer_ptr specialized algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
8.12.7 observer_ptr hash support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
9 Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9.1 Uniform container erasure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
v
© ISO/IEC 2017 — All rights reserved

9.1.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9.1.2 Function template erase_if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
9.1.3 Function template erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
9.2 Class template array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
9.2.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
9.2.2 Array creation functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
10 Iterators library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
10.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
10.2 Class template ostream_joiner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
10.2.1 ostream_joiner constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
10.2.2 ostream_joiner operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
10.2.3 ostream_joiner creation function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
11 Futures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.2 Class template promise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.3 Class template packaged_task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
12 Algorithms library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
12.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
12.2 Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
12.3 Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
12.4 Shuffle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
13 Numerics library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
13.1 Generalized numeric operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
13.1.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
13.1.2 Greatest common divisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
13.1.3 Least common multiple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
13.2 Random number generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
13.2.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
13.2.2 Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
13.2.2.1 Function template randint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
14 Reflection library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
14.1 Class source_location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
14.1.1 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . 113
14.1.2 source_location creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
14.1.3 source_location field access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
vi
© ISO/IEC 2017 — All rights reserved

Foreword
ISO (the International Organization for Standardization) is a worldwide federation of national standards bodies (ISO
member bodies). The work of preparing International Standards is normally carried out through ISO technical
committees. Each member body interested in a subject for which a technical committee has been established has the right
to be represented on that committee. International organizations, governmental and non-governmental, in liaison with
ISO, also take part in the work. ISO collaborates closely with the International Electrotechnical Commission (IEC) on all
matters of electrotechnical standardization.
The procedures used to develop this document and those intended for its further maintenance are described in the ISO/
IEC Directives, Part 1. In particular the different approval criteria needed for the different types of ISO documents should
be noted. This document was drafted in accordance with the editorial rules of the ISO/IEC Directives, 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 patent rights. ISO
shall not be held responsible for identifying any or all such patent rights. Details of any patent rights identified during the
development of the document will be in the Introduction and/or on the ISO list of patent declarations received (see
www.iso.org/patents).
Any trade name used in this document is information given for the convenience of users and does not constitute an
endorsement. For an explanation on the voluntary nature of standards, the meaning of ISO specific terms and expressions
related 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 the following URL: 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 edition of ISO/IEC 19568:2017
cancels and replaces the edition ISO/IEC 19568:2015, which has been technically revised and includes the following
changes:
— Addition of the sample algorithm.
— Addition of new random-number generation facilities, and algorithms which use them.
— Addition of algorithms for uniform container erasure.
— Addition of function template not_fn.
— Addition of logical operator type traits conjunction, disjunction, and negation.
— Addition of templates to support the "detection idiom".
— Addition of the propagate_const class template.
— Addition of the observer_ptr class template.
— Addition of the make_array and to_array function templates.
— Addition of the ostream_joiner class template.
— Addition of the gcd and lcm algorithms.
— Addition of the source_location struct.
— Changes to the return types of search algorithms.
— Moving all libraries to the inline namespace fundamentals_v2.
— Miscellaneous defect resolutions.
vii
© ISO/IEC 2017 — All rights reserved

1 General [general]
1.1 Scope [general.scope]
This technical specification describes extensions to the C++ Standard Library (1.2). These extensions are classes and
functions that are likely to be used widely within a program and/or on the interface boundaries between libraries written
by different organizations.
This technical specification is non-normative. Some of the library components in this technical specification may be
considered for standardization in a future version of C++, but they are not currently part of any C++ standard. Some of
the components in this technical specification may never be standardized, and others may be standardized in a
substantially changed form.
The goal of this technical specification is to build more widespread existing practice for an expanded C++ standard
library. It gives advice on extensions to those vendors who wish to provide them.
1.2 Normative references [general.references]
The following referenced document is indispensable for the application of this document. For dated references, only the
edition cited applies. For undated references, the latest edition of the referenced document (including any amendments)
applies.
— ISO/IEC 14882:2014, Programming Languages — C++
ISO/IEC 14882:2014 is herein called the C++ Standard. References to clauses within the C++ Standard are written as
"C++14 §3.2". The library described in ISO/IEC 14882:2014 clauses 17–30 is herein called the C++ Standard Library.
Unless otherwise specified, the whole of the C++ Standard's Library introduction (C++14 §17) is included into this
Technical Specification by reference.
1.3 Namespaces, headers, and modifications to standard classes [general.namespaces]
Since the extensions described in this technical specification are experimental and not part of the C++ standard library,
they should not be declared directly within namespace std. Unless otherwise specified, all components described in this
technical specification either:
— modify an existing interface in the C++ Standard Library in-place,
— are declared in a namespace whose name appends ::experimental::fundamentals_v2 to a namespace defined
in the C++ Standard Library, such as std or std::chrono, or
— are declared in a subnamespace of a namespace described in the previous bullet, whose name is not the same as
an existing subnamespace of namespace std.
[ Example: This TS does not define std::experimental::fundamentals_v2::chrono because the C++ Standard Library
defines std::chrono. This TS does not define std::pmr::experimental::fundamentals_v2 because the C++ Standard
Library does not define std::pmr. — end example ]
Each header described in this technical specification shall import the contents of std::experimental::fundamentals_v2
into std::experimental as if by
namespace std {
namespace experimental {
inline namespace fundamentals_v2 {}
© ISO/IEC 2017 — All rights reserved 1

}
}
This technical specification also describes some experimental modifications to existing interfaces in the C++ Standard
Library. These modifications are described by quoting the affected parts of the standard and using underlining to
represent added text and strike-through to represent deleted text.
Unless otherwise specified, references to other entities described in this technical specification are assumed to be
qualified with std::experimental::fundamentals_v2::, and references to entities described in the standard are
assumed to be qualified with std::.
Extensions that are expected to eventually be added to an existing header are provided inside the
header, which shall include the standard contents of as if by
#include
New headers are also provided in the directory, but without such an #include.
Table 1 — C++ library headers










1.4 Terms and definitions [general.defns]
For the purposes of this document, the terms and definitions given in the C++ Standard and the following apply.
1.4.1 [general.defns.direct-non-list-init]
direct-non-list-initialization
A direct-initialization that is not list-initialization.
1.5 Future plans (Informative) [general.plans]
This section describes tentative plans for future versions of this technical specification and plans for moving content into
future versions of the C++ Standard.
The C++ committee intends to release a new version of this technical specification approximately every year, containing
the library extensions we hope to add to a near-future version of the C++ Standard. Future versions will define their
contents in std::experimental::fundamentals_v3, std::experimental::fundamentals_v4, etc., with the most recent
implemented version inlined into std::experimental.
When an extension defined in this or a future version of this technical specification represents enough existing practice, it
will be moved into the next version of the C++ Standard by removing the experimental::fundamentals_vN segment of
its namespace and by removing the experimental/ prefix from its header's path.
2 © ISO/IEC 2017 — All rights reserved

1.6 Feature-testing recommendations (Informative) [general.feature.test]
For the sake of improved portability between partial implementations of various C++ standards, WG21 (the ISO technical
committee for the C++ programming language) recommends that implementers and programmers follow the guidelines in
this section concerning feature-test macros. [ Note: WG21's SD-6 makes similar recommendations for the C++ Standard
itself. — end note ]
Implementers who provide a new standard feature should define a macro with the recommended name, in the same
circumstances under which the feature is available (for example, taking into account relevant command-line options), to
indicate the presence of support for that feature. Implementers should define that macro with the value specified in the
most recent version of this technical specification that they have implemented. The recommended macro name is
"__cpp_lib_experimental_" followed by the string in the "Macro Name Suffix" column.
Programmers who wish to determine whether a feature is available in an implementation should base that determination
on the presence of the header (determined with __has_include(

)) and the state of the macro with the
recommended name. (The absence of a tested feature may result in a program with decreased functionality, or the relevant
functionality may be provided in a different way. A program that strictly depends on support for a feature can just try to
use the feature unconditionally; presumably, on an implementation lacking necessary support, translation will fail.)
Table 2 — Significant features in this technical specification
Primary
Doc. No. Title Macro Name Suffix Value Header
Section
apply() call a
function with
N3915 3.2.2 apply 201402
arguments from a
tuple
Variable Templates
N3932 3.3.1 type_trait_variable_templates 201402
For Type Traits
N3866 Invocation type traits 3.3.2 invocation_type 201406
Logical Operator
P0013R1 3.3.3 logical_traits 201511
Type Traits
The C++ Detection
N4502 3.3.4 detect 201505
Idiom
A Proposal to Add a
Const-Propagating
N4388 3.7 propagate_const 201505
Wrapper to the
Standard Library
Type-erased
N3916 allocator for 4.2 function_erased_allocator 201406
std::function
Extending
std::search to use
boyer_moore_searching
N3905 4.3 201411
Additional Searching
Algorithms
A proposal to add a
N4076 generalized callable 4.4 not_fn 201406
negator
A utility class to
N3672,
represent optional 5 optional 201411
N3793
objects
Any Library
N3804 6 any 201411
Proposal
© ISO/IEC 2017 — All rights reserved 3

Primary
Doc. No. Title Macro Name Suffix Value Header
Section
string_view: a non-
N3921 owning reference to 7 string_view 201411
a string
Extending shared_ptr
N3920 8.2 shared_ptr_arrays 201406
to Support Arrays
Polymorphic
N3916 8.4 memory_resources 201402
Memory Resources
The World’s
N4282 Dumbest Smart 8.12 observer_ptr 201411
Pointer
Uniform Container
N4273 9.1 erase_if 201411
Erasure
N4391 make_array 9.2.2 make_array 201505
N4257 Delimited iterators 10.2 ostream_joiner 201411
Type-erased
N3916 allocator for 11.2 promise_erased_allocator 201406
std::promise
Type-erased
N3916 allocator for 11.3 packaged_task_erased_allocator 201406
std::packaged_task
N3925 A sample Proposal 12.3 sample 201402
Greatest Common
13.1.2,
N4061 Divisor and Least gcd_lcm 201411
13.1.3
Common Multiple
std::rand
N4531 13.2.2.1 randint 201511
replacement
Source-Code
N4519 14.1 source_location 201505
Information Capture
4 © ISO/IEC 2017 — All rights reserved

2 Modifications to the C++ Standard Library [mods]
Implementations that conform to this technical specification shall behave as if the modifications contained in this section
are made to the C++ Standard.
2.1 Uses-allocator construction [mods.allocator.uses]
The following changes to the uses_allocator trait and to the description of uses-allocator construction allow a
memory_resource pointer act as an allocator in many circumstances. [ Note: Existing programs that use standard
allocators would be unaffected by this change. — end note ]
20.7.7 uses_allocator [allocator.uses]
20.7.7.1 uses_allocator trait [allocator.uses.trait]
template struct uses_allocator;
Remarks: Automatically detects whether T has a nested allocator_type that is convertible from Alloc.
Meets the BinaryTypeTrait requirements (C++14 §20.10.1). The implementation shall provide a
definition that is derived from true_type if a type T::allocator_type exists and either
is_convertible_v != false or T::allocator_type is an alias for
std::experimental::erased_type (3.1.2), otherwise it shall be derived from false_type. A program
may specialize this template to derive from true_type for a user-defined type T that does not have a
nested allocator_type but nonetheless can be constructed with an allocator where either:
— the first argument of a constructor has type allocator_arg_t and the second argument has type
Alloc or
— the last argument of a constructor has type Alloc.
20.7.7.2 uses-allocator construction [allocator.uses.construction]
Uses-allocator construction with allocator Alloc refers to the construction of an object obj of type T, using
constructor arguments v1, v2, ., vN of types V1, V2, ., VN, respectively, and an allocator alloc of
type Alloc, where Alloc either (1) meets the requirements of an allocator (C++14 §17.6.3.5), or (2) is a
pointer type convertible to std::experimental::pmr::memory_resource* (8.5), according to the following
rules:
© ISO/IEC 2017 — All rights reserved 5

ISO/IEC T
...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.

Loading comments...