ISO/IEC TR 19768:2007
(Main)Information technology — Programming languages — Technical Report on C++ Library Extensions
Information technology — Programming languages — Technical Report on C++ Library Extensions
ISO/IEC TR 19768:2007 specifies a series of extensions to the standard library for the programming language C++, as specified by ISO/IEC 14882, in order to build more widespread existing practice for an expanded C++ standard library. Some of the components in ISO/IEC TR 19768:2007 could be considered for standardization in a future version of C++. The specific classes of extensions specified in ISO/IEC TR 19768:2007 are as follows: general utilities such as reference-counted pointers; functional programming; facilities for compile-time type queries; enhanced support for numerical computation; hash tables and other additional container classes; regular expression processing; improved capability with the programming language C, as specified by ISO/IEC 9899.
Technologies de l'information — Langages de programmation — Rapport technique sur l'extensions des librairies C++
General Information
Standards Content (Sample)
TECHNICAL ISO/IEC
REPORT TR
First edition
2007-11-15
Information technology — Programming
languages — Technical Report on C++
Library Extensions
Technologies de l'information — Langages de programmation —
Rapport technique sur l'extensions des librairies C++
Reference number
©
ISO/IEC 2007
PDF disclaimer
PDF files may contain embedded typefaces. In accordance with Adobe's licensing policy, such files may be printed or viewed but shall
not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In
downloading a PDF file, parties accept therein the responsibility of not infringing Adobe's licensing policy. The ISO Central Secretariat
accepts no liability in this area.
Adobe is a trademark of Adobe Systems Incorporated.
Details of the software products used to create the PDF file(s) constituting this document can be found in the General Info relative to
the file(s); the PDF-creation parameters were optimized for printing. Every care has been taken to ensure that the files are suitable for
use by ISO member bodies. In the unlikely event that a problem relating to them is found, please inform the Central Secretariat at the
address given below.
This CD-ROM contains:
1) the publication ISO/IEC TR 19768:2007 in portable document format (PDF), which can be viewed
using Adobe® Acrobat® Reader;
2) electronic attachments containing C++ Library Extension software.
Adobe and Acrobat are trademarks of Adobe Systems Incorporated.
© ISO/IEC 2007
All rights reserved. Unless required for installation or otherwise specified, no part of this CD-ROM may be reproduced, stored in a retrieval
system or transmitted in any form or by any means without prior permission from ISO. Requests for permission to reproduce this product
should be addressed to
ISO copyright office • Case
...
TECHNICAL ISO/IEC
REPORT TR
First edition
2007-11-15
Information technology — Programming
languages — Technical Report on C++
Library Extensions
Technologies de l'information — Langages de programmation —
Rapport technique sur l'extensions des librairies C++
Reference number
©
ISO/IEC 2007
PDF disclaimer
This PDF file may contain embedded typefaces. In accordance with Adobe's licensing policy, this file may be printed or viewed but
shall not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In
downloading this file, parties accept therein the responsibility of not infringing Adobe's licensing policy. The ISO Central Secretariat
accepts no liability in this area.
Adobe is a trademark of Adobe Systems Incorporated.
Details of the software products used to create this PDF file can be found in the General Info relative to the file; the PDF-creation
parameters were optimized for printing. Every care has been taken to ensure that the file is suitable for use by ISO member bodies. In
the unlikely event that a problem relating to it is found, please inform the Central Secretariat at the address given below.
© ISO/IEC 2007
All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized in any form or by any means,
electronic or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or
ISO's member body in the country of the requester.
ISO copyright office
Case postale 56 • CH-1211 Geneva 20
Tel. + 41 22 749 01 11
Fax + 41 22 749 09 47
E-mail copyright@iso.org
Web www.iso.org
Published in Switzerland
ii © ISO/IEC 2007 – All rights reserved
Contents
Foreword x
ListofTables xi
1 1
Scope
1.1 RelationtoC++StandardLibraryIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Categoriesofextensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Namespacesandheaders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 GeneralUtilities 3
2.1 Referencewrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.1 Additionstoheadersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.2 Classtemplatereference_wrapper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.2.1 reference_wrapperconstruct/copy/destroy . . . . . . . . . . . . . . . . . . . . . 4
2.1.2.2 reference_wrapperassignment . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2.3 reference_wrapperaccess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2.4 reference_wrapperinvocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2.5 reference_wrapperhelperfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Smartpointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.1 Additionstoheadersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.2 Classbad_weak_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.3 Classtemplateshared_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.3.1 shared_ptrconstructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.3.2 shared_ptrdestructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.3.3 shared_ptrassignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.3.4 shared_ptrmodifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.3.5 shared_ptrobservers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.3.6 shared_ptrcomparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.3.7 shared_ptrI/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.3.8 shared_ptrspecializedalgorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.3.9 shared_ptrcasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.3.10 get_deleter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.4 Classtemplateweak_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.4.1 weak_ptrconstructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
© ISO/IEC 2007 – All rights reserved iii
CONTENTS CONTENTS iv
2.2.4.2 weak_ptrdestructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.4.3 weak_ptrassignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.4.4 weak_ptrmodifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.4.5 weak_ptrobservers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.4.6 weak_ptrcomparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.4.7 weak_ptrspecializedalgorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.5 Classtemplateenable_shared_from_this . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3 Functionobjects 21
3.1 Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2 Additionstosynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.4 Functionreturntypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.5 Functiontemplatemem_fn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.6 Functionobjectbinders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.6.1 Classtemplateis_bind_expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.6.2 Classtemplateis_placeholder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.6.3 Functiontemplatebind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.6.4 Placeholders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.7 Polymorphicfunctionwrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.7.1 Classbad_function_call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.7.1.1 bad_function_callconstructor . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.7.2 Classtemplatefunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.7.2.1 functionconstruct/copy/destroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.7.2.2 functionmodifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.7.2.3 functioncapacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.7.2.4 functioninvocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.7.2.5 functiontargetaccess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.7.2.6 undefinedoperators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.7.2.7 nullpointercomparisonoperators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.7.2.8 specializedalgorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4 Metaprogrammingandtypetraits 33
4.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2 Headersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.3 Helperclasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.4 GeneralRequirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.5 UnaryTypeTraits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.5.1 PrimaryTypeCategories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.5.2 Compositetypetraits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.5.3 Typeproperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.6 Relationshipsbetweentypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.7 Transformationsbetweentypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.7.1 Const-volatilemodifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.7.2 Referencemodifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.7.3 Arraymodifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
iv © ISO/IEC 2007 – All rights reserved
v CONTENTS CONTENTS
4.7.4 Pointermodifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.8 Othertransformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.9 Implementationrequirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5 Numericalfacilities 45
5.1 Randomnumbergeneration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.1.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.1.2 Headersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.1.3 Classtemplatevariate_generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.1.4 Randomnumberengineclasstemplates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.1.4.1 Classtemplatelinear_congruential . . . . . . . . . . . . . . . . . . . . . . . . 53
5.1.4.2 Classtemplatemersenne_twister . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.1.4.3 Classtemplatesubtract_with_carry . . . . . . . . . . . . . . . . . . . . . . . . 55
5.1.4.4 Classtemplatesubtract_with_carry_01 . . . . . . . . . . . . . . . . . . . . . . 57
5.1.4.5 Classtemplatediscard_block . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.1.4.6 Classtemplatexor_combine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.1.5 Engineswithpredefinedparameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.1.6 Classrandom_device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.1.7 Randomdistributionclasstemplates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.1.7.1 Classtemplateuniform_int . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.1.7.2 Classbernoulli_distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.1.7.3 Classtemplategeometric_distribution . . . . . . . . . . . . . . . . . . . . . . 65
5.1.7.4 Classtemplatepoisson_distribution . . . . . . . . . . . . . . . . . . . . . . . . 65
5.1.7.5 Classtemplatebinomial_distribution . . . . . . . . . . . . . . . . . . . . . . . 66
5.1.7.6 Classtemplateuniform_real . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.1.7.7 Classtemplateexponential_distribution . . . . . . . . . . . . . . . . . . . . . 67
5.1.7.8 Classtemplatenormal_distribution . . . . . . . . . . . . . . . . . . . . . . . . 68
5.1.7.9 Classtemplategamma_distribution . . . . . . . . . . . . . . . . . . . . . . . . . 69
5.2 Mathematicalspecialfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
5.2.1 Additionstoheadersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
5.2.1.1 associatedLaguerrepolynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.2.1.2 associatedLegendrefunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.2.1.3 betafunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.2.1.4 (complete)ellipticintegralofthefirstkind . . . . . . . . . . . . . . . . . . . . . . . 74
5.2.1.5 (complete)ellipticintegralofthesecondkind . . . . . . . . . . . . . . . . . . . . . 74
5.2.1.6 (complete)ellipticintegralofthethirdkind . . . . . . . . . . . . . . . . . . . . . . . 75
5.2.1.7 confluenthypergeometricfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.2.1.8 regularmodifiedcylindricalBesselfunctions . . . . . . . . . . . . . . . . . . . . . . 75
5.2.1.9 cylindricalBesselfunctions(ofthefirstkind) . . . . . . . . . . . . . . . . . . . . . 75
5.2.1.10 irregularmodifiedcylindricalBesselfunctions . . . . . . . . . . . . . . . . . . . . . 76
5.2.1.11 cylindricalNeumannfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.2.1.12 (incomplete)ellipticintegralofthefirstkind . . . . . . . . . . . . . . . . . . . . . . 77
5.2.1.13 (incomplete)ellipticintegralofthesecondkind . . . . . . . . . . . . . . . . . . . . 77
5.2.1.14 (incomplete)ellipticintegralofthethirdkind . . . . . . . . . . . . . . . . . . . . . 77
5.2.1.15 exponentialintegral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
5.2.1.16 Hermitepolynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
© ISO/IEC 2007 – All rights reserved v
CONTENTS CONTENTS vi
5.2.1.17 hypergeometricfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.2.1.18 Laguerrepolynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.2.1.19 Legendrepolynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.2.1.20 Riemannzetafunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.2.1.21 sphericalBesselfunctions(ofthefirstkind) . . . . . . . . . . . . . . . . . . . . . . 79
5.2.1.22 sphericalassociatedLegendrefunctions . . . . . . . . . . . . . . . . . . . . . . . . 80
5.2.1.23 sphericalNeumannfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
5.2.2 Additionstoheadersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6 Containers 81
6.1 Tupletypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.1.1 Headersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.1.2 Additionstoheadersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.1.3 Classtemplatetuple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.1.3.1 Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.1.3.2 Tuplecreationfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.1.3.3 Tuplehelperclasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.1.3.4 Elementaccess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
6.1.3.5 Relationaloperators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
6.1.4 Pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.2 Fixedsizearray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.2.1 Headersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.2.2 Classtemplatearray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.2.2.1 arrayconstructors,copy,andassignment . . . . . . . . . . . . . . . . . . . . . . . 90
6.2.2.2 arrayspecializedalgorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.2.2.3 arraysize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.2.2.4 Zerosizedarrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.2.2.5 Tupleinterfacetoclasstemplatearray . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.3 Unorderedassociativecontainers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
6.3.1 Unorderedassociativecontainerrequirements . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
6.3.1.1 Exceptionsafetyguarantees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
6.3.2 Additionstoheadersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6.3.3 Classtemplatehash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6.3.4 Unorderedassociativecontainerclasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
6.3.4.1 Headersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . 98
6.3.4.2 Headersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . 98
6.3.4.3 Classtemplateunordered_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.3.4.3.1 unordered_setconstructors . . . . . . . . . . . . . . . . . . . . . . . . . 101
6.3.4.3.2 unordered_setswap . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
6.3.4.4 Classtemplateunordered_map . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
6.3.4.4.1 unordered_mapconstructors . . . . . . . . . . . . . . . . . . . . . . . . . 104
6.3.4.4.2 unordered_mapelementaccess . . . . . . . . . . . . . . . . . . . . . . . 105
6.3.4.4.3 unordered_mapswap . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.3.4.5 Classtemplateunordered_multiset . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.3.4.5.1 unordered_multisetconstructors . . . . . . . . . . . . . . . . . . . . . 107
6.3.4.5.2 unordered_multisetswap . . . . . . . . . . . . . . . . . . . . . . . . . 108
vi © ISO/IEC 2007 – All rights reserved
vii CONTENTS CONTENTS
6.3.4.6 Classtemplateunordered_multimap . . . . . . . . . . . . . . . . . . . . . . . . . 108
6.3.4.6.1 unordered_multimapconstructors . . . . . . . . . . . . . . . . . . . . . 110
6.3.4.6.2 unordered_multimapswap . . . . . . . . . . . . . . . . . . . . . . . . . 111
7 Regularexpressions 113
7.1 Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
7.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
7.3 Regularexpressionssummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
7.4 Headersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
7.5 Namespacetr1::regex_constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
7.5.1 BitmaskTypesyntax_option_type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
7.5.2 BitmaskTyperegex_constants::match_flag_type . . . . . . . . . . . . . . . . . . . . . 122
7.5.3 Implementationdefinederror_type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
7.6 Classregex_error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
7.7 Classtemplateregex_traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
7.8 Classtemplatebasic_regex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
7.8.1 basic_regexconstants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
7.8.2 basic_regexconstructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
7.8.3 basic_regexassign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
7.8.4 basic_regexconstantoperations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
7.8.5 basic_regexlocale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
7.8.6 basic_regexswap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
7.8.7 basic_regexnon-memberfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
7.8.7.1 basic_regexnon-memberswap . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
7.9 Classtemplatesub_match . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
7.9.1 sub_matchmembers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
7.9.2 sub_matchnon-memberoperators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
7.10 Classtemplatematch_results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
7.10.1 match_resultsconstructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
7.10.2 match_resultssize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
7.10.3 match_resultselementaccess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
7.10.4 match_resultsformatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
7.10.5 match_resultsallocator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
7.10.6 match_resultsswap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
7.11 Regularexpressionalgorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
7.11.1 exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
7.11.2 regex_match . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
7.11.3 regex_search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
7.11.4 regex_replace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
7.12 RegularexpressionIterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
7.12.1 Classtemplateregex_iterator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
7.12.1.1 regex_iteratorconstructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
7.12.1.2 regex_iteratorcomparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
7.12.1.3 regex_iteratordereference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
7.12.1.4 regex_iteratorincrement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
7.12.2 Classtemplateregex_token_iterator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
© ISO/IEC 2007 – All rights reserved vii
CONTENTS CONTENTS viii
7.12.2.1 regex_token_iteratorconstructors . . . . . . . . . . . . . . . . . . . . . . . . . 150
7.12.2.2 regex_token_iteratorcomparisons . . . . . . . . . . . . . . . . . . . . . . . . . 151
7.12.2.3 regex_token_iteratordereference . . . . . . . . . . . . . . . . . . . . . . . . . 151
7.12.2.4 regex_token_iteratorincrement . . . . . . . . . . . . . . . . . . . . . . . . . . 151
7.13 ModifiedECMAScriptregularexpressiongrammar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
8 Ccompatibility 155
8.1 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
8.1.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
8.1.2 Functionacos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
8.1.3 Functionasin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
8.1.4 Functionatan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
8.1.5 Functionacosh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
8.1.6 Functionasinh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
8.1.7 Functionatanh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
8.1.8 Functionfabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
8.1.9 AdditionalOverloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
8.2 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
8.3 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
8.4 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
8.4.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
8.4.2 Functionisblank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
8.5 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
8.6 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
8.6.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
8.6.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
8.7 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
8.8 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
8.9 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
8.10 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
8.10.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
8.10.2 Functionhexfloat. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
8.11 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
8.11.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
8.11.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
8.12 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
8.13 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
8.14 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
8.15 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
8.16 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
8.16.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
8.16.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
8.16.3 Functiontemplatedefinitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
8.16.4 Additionaloverloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
8.17 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
8.18 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
viii © ISO/IEC 2007 – All rights reserved
ix CONTENTS CONTENTS
8.19 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
8.20 Theheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
8.21 Theheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
8.22 Theheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
8.22.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
8.22.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
8.23 Theheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
8.24 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
8.24.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
8.24.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
8.24.3 Additionalformatspecifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
8.24.4 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
8.25 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
8.25.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
8.25.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.25.3 Functionabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.25.4 Functiondiv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.26 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.27 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.28 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.29 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.30 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.30.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.30.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
8.30.3 Additionalwideformatspecifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
8.31 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
8.32 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
8.32.1 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
8.32.2 Functioniswblank. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
8.33 Additionstoheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
A Implementationquantities 171
Bibliography 173
Index 175
© ISO/IEC 2007 – All rights reserved ix
Foreword
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical
Commission) form the specialized system for worldwide standardization. National bodies that are members of
ISO or IEC participate in the development of International Standards through technical committees
established by the respective organization to deal with particular fields of technical activity. ISO and IEC
technical committees collaborate in fields of mutual interest. Other international organizations, governmental
and non-governmental, in liaison with ISO and IEC, also take part in the work. In the field of information
technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1.
International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 2.
The main task of the joint technical committee is to prepare International Standards. Draft International
Standards adopted by the joint technical committee are circulated to national bodies for voting. Publication as
an International Standard requires approval by at least 75 % of the national bodies casting a vote.
In exceptional circumstances, the joint technical committee may propose the publication of a Technical Report
of one of the following types:
— type 1, when the required support cannot be obtained for the publication of an International Standard,
despite repeated efforts;
— type 2, when the subject is still under technical development or where for any other reason there is the
future but not immediate possibility of an agreement on an International Standard;
— type 3, when the joint technical committee has collected data of a different kind from that which is normally
published as an International Standard (“state of the art”, for example).
Technical Reports of types 1 and 2 are subject to review within three years of publication, to decide whether
they can be transformed into International Standards. Technical Reports of type 3 do not necessarily have to
be reviewed until the data they provide are considered to be no longer valid or useful.
Attention is drawn to the possibility that some of the elements of this document may be the subject of patent
rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights.
ISO/IEC TR 19768, which is a Technical Report of type 2, was prepared by Joint Technical Committee
ISO/IEC JTC 1, Information technology, Subcommittee SC 22, Programming languages, their environments
and system software interfaces.
© ISO/IEC 2007 – All rights reserved
x
ListofTables
1 Utilitieslibrarysummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Functionobjectlibrarysummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3 Typetraitslibrarysummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4 PrimaryTypeCategoryPredicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5 CompositeTypeCategoryPredicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6 TypePropertyPredicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7 TypePropertyQueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8 TypeRelationshipPredicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
9 Const-volatilemodifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
10 Referencemodifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
11 Arraymodifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
12 Pointermodifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
13 Othertransformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
14 Numericallibrarysummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
15 Uniformrandomnumbergeneratorrequirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
16 Pseudo-random number engine requirements (in addition to uniform random number generator, Copy-
Constructible,andAssignable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
17 Randomdistributionrequirements(inadditiontoCopyConstructible,andAssignable) . . . . . . . 48
18 Additionstoheadersynopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
19 Containerlibrarysummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
20 Containerrequirementsthatarenotrequiredforunorderedassociativecontainers . . . . . . . . . . . . 91
21 Unorderedassociativecontainerrequirements(inadditiontocontainer) . . . . . . . . . . . . . . . . . 92
22 regularexpressiontraitsclassrequirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
23 syntax_option_typeeffects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
24 regex_constants::match_flag_type effects when obtaining a match against a character container
sequence[first,last). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
25 error_typevaluesintheClocale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
26 match_resultsassignmentoperatoreffects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
27 Effectsofregex_matchalgorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
28 Effectsofregex_searchalgorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
© ISO/IEC 2007 – All rights reserved xi
TECHNICAL REPORT ISO/IEC TR 19768:2007(E)
Scope1 [tr.intro]
1 This Technical Report describes extensions to the C++ standard library that is described in the International
Standard for the C++ programming language [14].
2 This Technical Report is non-normative. Some of the library components in this Technical Report 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 Report may never be standardized, and others may be standardized in a substantially
changed form.
3 The goal of this Technical Report 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.1 Relation to C++ Standard Library Introduction [tr.description]
1 Unless otherwise specified, the whole of the ISO C++ Standard Library introduction [lib.library] is included in this
Technical Report by reference.
1.2 Categories of extensions [tr.intro.ext]
1 This Technical Report describes four general categories of library extensions:
1. New requirement tables, such as the regular expression traits requirements in 7.2. These are not directly
expressed as software; they specify the circumstances under which user-written components will interoperate
with the components described in this Technical Report.
2. New library components (types and functions) that are declared in entirely new headers, such as the class
templates in the header (6.3.4.1).
3. New library components declared as additions to existing standard headers, such as the mathematical special
functions added to the headers and in 5.2.1 and 5.2.2
4. Additions to standard library components, such as the extensions to class std::pair in 6.1.4.
2 New headers are distinguished from extensions to existing headers by the title of the synopsis clause. In the first case,
the title is of the form “Header synopsis”, and the synopsis includes all namespace scope declarations
contained in the header. In the second case, the title is of the form “Additions to header synopsis” and the
synopsis includes only the extensions, i.e. those namespace scope declarations that are not present in the C++
standard [14].
© ISO/IEC 2007 – All rights reserved 1
1.3 Namespaces and headers Scope 2
1.3 Namespaces and headers [tr.intro.namespaces]
1 Since the extensions described in this Technical Report are not part of the C++ standard library, they should not be
declared directly within namespace std. Unless otherwise specifed, all components described in this Technical Report
are declared in namespace std::tr1. [Note: Some components are declared in subnamespaces of namespace std::tr1.
—end note]
2 Unless otherwise specified, references to other entities described in this Technical Report are assumed to be qualified
with std::tr1::, and references to entities described in the International Standard are assumed to be qualified with
std::.
3 Even when an extension is specified as additions to standard headers (the third category in 1.2), vendors should not
simply add declarations to standard headers in a way that would be visible to users by default. [Note: That would fail
to be standard conforming, because the new names, even within a namespace, could conflict with user macros. —end
note] Users should be required to take explicit action to have access to library extensions.
4 It is recommended either that additional declarations in standard headers be protected with a macro that is not
defined by default, or else that all extended headers, including both new headers and parallel versions of standard
headers with non-standard declarations, be placed in a separate directory that is not part of the default search path.
2 © ISO/IEC 2007 – All rights reserved
2 GeneralUtilities [tr.util]
++
1 This clause describes basic components used to implement other library facilities. They may also be used by C
programs.
2 Thefollowingsubclausesdescribereferencewrappersandsmartpointers,assummarizedinTable1.
Table1: Utilitieslibrarysummary
Subclause Header(s)
2.1Referencewrapper
2.2Smartpointers
2.1 Referencewrappers [tr.util.refwrap]
2.1.1 Additionstoheadersynopsis [tr.util.refwrp.synopsis]
namespace std {
namespace tr1 {
template class reference_wrapper;
template reference_wrapper ref(T&);
template reference_wrapper cref(const T&);
template reference_wrapper ref(reference_wrapper);
template reference_wrapper cref(reference_wrapper);
} // namespacetr1
} // namespacestd
2.1.2 Classtemplatereference_wrapper [tr.util.refwrp.refwrp]
template class reference_wrapper
: public unary_function //seebelow
: public binary_function //seebelow
{
public :
// types
typedef T type;
typedef see below result_type; //Notalwaysdefined
© ISO/IEC 2007 – All rights reserved 3
2.1 Referencewrappers GeneralUtilities 4
// construct/copy/destroy
explicit reference_wrapper(T&);
reference_wrapper(const reference_wrapper& x);
// assignment
reference_wrapper& operator=(const reference_wrapper& x);
// access
operator T& () const;
T& get() const;
// invocation
template
typename result_of::type
operator() (T1&, T2&, ., TN&) const;
};
1 reference_wrapperisaCopyConstructibleandAssignablewrapperaroundareferencetoanobjectoftypeT.
2 reference_wrapperhasaweakresulttype([3.3]).
3 Thetemplateinstantiationreference_wrappershallbederivedfromstd::unary_functiononlyifthe
typeTisanyofthefollowing:
— afunctiontypeorapointertofunctiontypetakingoneargumentoftypeT1andreturningR
— apointertomemberfunctiontypewithcv-qualifier cvandnoarguments;thetypeT1iscv T*andRisthereturn
typeofthepointertomemberfunction
— aclasstypethatisderivedfromstd::unary_function
4 The template instantiation reference_wrapper shall be derived from std::binary_function
onlyifthetypeTisanyofthefollowing:
— afunctiontypeorapointertofunctiontypetakingtwoargumentsoftypesT1andT2andreturningR
— a pointer to member function with cv-qualifier cv and taking one argument of type T2; the type T1 is cv T* and
Risthereturntypeofthepointertomemberfunction
— aclasstypethatisderivedfromstd::binary_function
2.1.2.1 reference_wrapperconstruct/copy/destroy [tr.util.refwrp.const]
explicit reference_wrapper(T& t);
1 Effects:Constructsareference_wrapperobjectthatstoresareferencetot
...










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...