1、Information technology Pr ogramming languages C+CAN/CSA-ISO/IEC 14882:13(ISO/IEC 14882:2011, IDT)National Standard of CanadaNOT FOR RESALE. / PUBLICATION NON DESTINE LA REVENTE.Legal Notice for StandardsCanadian Standards Association (operating as “CSA Group”) develops standards through a consensus
2、standards development process approved by the Standards Council of Canada. This process brings together volunteers representing varied viewpoints and interests to achieve consensus and develop a standard. Although CSA Group administers the process and establishes rules to promote fairness in achievi
3、ng consensus, it does not independently test, evaluate, or verify the content of standards.Disclaimer and exclusion of liabilityThis document is provided without any representations, warranties, or conditions of any kind, express or implied, including, without limitation, implied warranties or condi
4、tions concerning this documents fitness for a particular purpose or use, its merchantability, or its non-infringement of any third partys intellectual property rights. CSA Group does not warrant the accuracy, completeness, or currency of any of the information published in this document. CSA Group m
5、akes no representations or warranties regarding this documents compliance with any applicable statute, rule, or regulation. IN NO EVENT SHALL CSA GROUP, ITS VOLUNTEERS, MEMBERS, SUBSIDIARIES, OR AFFILIATED COMPANIES, OR THEIR EMPLOYEES, DIRECTORS, OR OFFICERS, BE LIABLE FOR ANY DIRECT, INDIRECT, OR
6、INCIDENTAL DAMAGES, INJURY, LOSS, COSTS, OR EXPENSES, HOWSOEVER CAUSED, INCLUDING BUT NOT LIMITED TO SPECIAL OR CONSEQUENTIAL DAMAGES, LOST REVENUE, BUSINESS INTERRUPTION, LOST OR DAMAGED DATA, OR ANY OTHER COMMERCIAL OR ECONOMIC LOSS, WHETHER BASED IN CONTRACT, TORT (INCLUDING NEGLIGENCE), OR ANY O
7、THER THEORY OF LIABILITY, ARISING OUT OF OR RESULTING FROM ACCESS TO OR POSSESSION OR USE OF THIS DOCUMENT, EVEN IF CSA GROUP HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, INJURY, LOSS, COSTS, OR EXPENSES.In publishing and making this document available, CSA Group is not undertaking to render
8、 professional or other services for or on behalf of any person or entity or to perform any duty owed by any person or entity to another person or entity. The information in this document is directed to those who have the appropriate degree of experience to use and apply its contents, and CSA Group a
9、ccepts no responsibility whatsoever arising in any way from any and all use of or reliance on the information contained in this document. CSA Group is a private not-for-profit company that publishes voluntary standards and related documents. CSA Group has no power, nor does it undertake, to enforce
10、compliance with the contents of the standards or other documents it publishes. Intellectual property rights and ownershipAs between CSA Group and the users of this document (whether it be in printed or electronic form), CSA Group is the owner, or the authorized licensee, of all works contained herei
11、n that are protected by copyright, all trade-marks (except as otherwise noted to the contrary), and all inventions and trade secrets that may be contained in this document, whether or not such inventions and trade secrets are protected by patents and applications for patents. Without limitation, the
12、 unauthorized use, modification, copying, or disclosure of this document may violate laws that protect CSA Groups and/or others intellectual property and may give rise to a right in CSA Group and/or others to seek legal redress for such use, modification, copying, or disclosure. To the extent permit
13、ted by licence or by law, CSA Group reserves all intellectual property rights in this document.Patent rightsAttention is drawn to the possibility that some of the elements of this standard may be the subject of patent rights. CSA Group shall not be held responsible for identifying any or all such pa
14、tent rights. Users of this standard are expressly advised that determination of the validity of any such patent rights is entirely their own responsibility.Authorized use of this documentThis document is being provided by CSA Group for informational and non-commercial use only. The user of this docu
15、ment is authorized to do only the following:If this document is in electronic form:sLOADTHISDOCUMENTONTOACOMPUTERFORTHESOLEPURPOSEOFREVIEWINGITsSEARCHANDBROWSETHISDOCUMENTANDsPRINTTHISDOCUMENTIFITISIN0$ cet aspect demeurant la responsabilit permanente de lOEN. Toute NNC reflte un consensus raisonnab
16、le parmi les points de vue dun certain nombre de personnes comptentes dont les intrts runis forment, au degr le plus lev possible, une reprsentation quilibre des intrts des producteurs, des organismes de rglementation, des utilisateurs (y compris les consommateurs) et dautres personnes intresses, se
17、lon le domaine envisag. Il sagit gnralement dune norme qui peut apporter une contribution apprciable, en temps opportun, lintrt national.Il est recommand aux personnes qui ont besoin de normes de se servir des Normes nationales du Canada. Ces normes font lobjet dexamens priodiques; cest pourquoi lon
18、 recommande aux utilisateurs de se procurer ldition la plus rcente de la norme auprs de lorganisme qui la publie.La responsabilit dapprouver les normes en tant que Normes nationales du Canada incombe au :Conseil canadien des normes270, rue Albert, bureau 200Ottawa (Ontario) K1P 6N7CanadaThis Nationa
19、l Standard of Canada is available in English and French.Bien que le but premier vis par cette norme soit nonc sous sa rubrique Domainedapplication, il est important de retenir quil incombe lutilisateur de juger si la normeconvient ses besoins particuliers.MCUne marque de commerce de lAssociation can
20、adienne de normalisation,qui exerce ses activits sous le nom Groupe CSA. TMA trade-mark of the Canadian Standards Association, operating as “CSA Group”National Standard of CanadaPublished in January 2013 by CSA GroupA not-for-profit private sector organization5060 Spectrum Way, Suite 100, Mississaug
21、a, Ontario, Canada L4W 5N61-800-463-6727 416-747-4044Visit our Online Store at shop.csa.caApproved byStandards Council of CanadaCAN/CSA-ISO/IEC 14882:13Information technology Programming languages C+Prepared by InternationalOrganizationforStandardization/ International Electrotechnical CommissionRev
22、iewed byCAN/CSA-ISO/IEC 14882:13 Information technology Programming languages C+CSA/4 2013 CSA Group January 2013CAN/CSA-ISO/IEC 14882:13Information technology Programming languages C+CSA PrefaceStandards development within the Information Technology sector is harmonized with international standards
23、 development. Through the CSA Technical Committee on Information Technology (TCIT), Canadians serve as the Canadian Advisory Committee (CAC) on ISO/IEC Joint Technical Committee 1 on Information Technology (ISO/IEC JTC1) for the Standards Council of Canada (SCC), the ISO member body for Canada and s
24、ponsor of the Canadian National Committee of the IEC. Also, as a member of the International Telecommunication Union (ITU), Canada participates in the International Telegraph and Telephone Consultative Committee (ITU-T).This Standard supersedes CAN/CSA-ISO/IEC 14882-04 (adoption of ISO/IEC 14882:200
25、3).At the time of publication, ISO/IEC 14882:2011 is available from ISO and IEC in English only. CSA Group will publish the French version when it becomes available from ISO and IEC.This International Standard was reviewed by the TCIT under the jurisdiction of the Strategic Steering Committee on Inf
26、ormation Technology and deemed acceptable for use in Canada. From time to time, ISO/IEC may publish addenda, corrigenda, etc. The TCIT will review these documents for approval and publication. For a listing, refer to the Current Standards Activities page at standardsactivities.csa.ca. This Standard
27、has been formally approved, without modification, by the Technical Committee and has been approved as a National Standard of Canada by the Standards Council of Canada. 2013 CSA GroupAll rights reserved. No part of this publication may be reproduced in any form whatsoever without the prior permission
28、 of thepublisher. ISO/IEC material is reprinted with permission. Where the words “this International Standard” appear in the text, they should be interpreted as “this National Standard of Canada”.Inquiries regarding this National Standard of Canada should be addressed toCSA Group5060 Spectrum Way, S
29、uite 100, Mississauga, Ontario, Canada L4W 5N61-800-463-6727 416-747-4000http:/csa.caTo purchase standards and related publications, visit our Online Store at shop.csa.ca or call toll-free 1-800-463-6727 or 416-747-4044.This Standard is subject to periodic review, and suggestions for its improvement
30、 will be referred to the appropriate committee. To submit a proposal for change, please send the following information to inquiriescsagroup.org and include “Proposal for change” in the subject line:(a) Standard designation (number);(b) relevant clause, table, and/or figure number;(c) wording of the
31、proposed change; and(d) rationale for the change.Reference numberISO/IEC 14882:2011(E)ISO/IEC 2011INTERNATIONAL STANDARD ISO/IEC14882Third edition2011-09-01Information technology Programming languages C+ Technologies de linformation Langages de programmation C+ ISO/IEC 14882:2011(E) COPYRIGHT PROTEC
32、TED DOCUMENT ISO/IEC 2011 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 ISOs
33、 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 copyrightiso.org Web www.iso.org ii ISO/IEC 2011 All rights reservedCAN/CSA-ISO/IEC 14882:13ContentsContents iiiList of Tables xiList of Figures xv
34、1 General 11.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Normative references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Terms and definitions . . . . . . . . . . . . . . . . . . . . . . . . .
35、. . . . . . . . . . . . . . . 21.4 Implementation compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.5 Structure of this International Standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.6 Syntax notation . . . . . . . . . . . . . . . . . . . . .
36、. . . . . . . . . . . . . . . . . . . . . . 61.7 The C+ memory model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.8 The C+ object model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.9 Program execution . . . . . . . . . . . . . . .
37、 . . . . . . . . . . . . . . . . . . . . . . . . . . 81.10 Multi-threaded executions and data races . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.11 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Lexical conventions 172.1 Separat
38、e translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.2 Phases of translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.3 Character sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
39、 . . . . . 182.4 Trigraph sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.5 Preprocessing tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.6 Alternative tokens . . . . . . . . . . . . . . . . . . . . . . . . .
40、. . . . . . . . . . . . . . . . 212.7 Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.8 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.9 Header names . . . . . . . . . . . . . . . . .
41、 . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.10 Preprocessing numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.11 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.12 Keywords . . . . . .
42、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.13 Operators and punctuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.14 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
43、Basic concepts 343.1 Declarations and definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343.2 One definition rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363.3 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
44、. . . . . . . . . . . . . . . . . . . 383.4 Name lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.5 Program and linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593.6 Start and termination . . . . . . . . . . .
45、. . . . . . . . . . . . . . . . . . . . . . . . . . . . 623.7 Storage duration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653.8 Object lifetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693.9 Types . . . . . . . . .
46、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723.10 Lvalues and rvalues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78ContentsiiiISO/IEC 14882:2011(E) ISO/IEC 2011 All rights reserved CAN/CSA-ISO/IEC 14882:133.11 Alignment . . .
47、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 804 Standard conversions 814.1 Lvalue-to-rvalue conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824.2 Array-to-pointer conversion . . . . . . . . . . . . . . . . . . . . . . . .
48、. . . . . . . . . . . . 824.3 Function-to-pointer conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824.4 Qualification conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824.5 Integral promotions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 834.6 Floating point promotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 844.7 Integral conversions . . . . . . . . . . . . . . . . . . .