Constexpr Library Additions: containers
ISO/IEC JTC1 SC22 WG21 N3304 = 11-0074 - 2011-08-17
Benjamin Kosnik, bkoz@redhat.com
Daniel Krugler, daniel.kruegler@googlemail.com
Introduction
This paper details use of the ISO C++0x constexpr feature, as initially introduced in “Generalized Constant Expressions — Revision 5” (N2235) and incorporating all other subsequent changes as per ISO C++ draft N3291. Several CWG issues have also influenced the language with respect to constexpr: see issues 1099, 1125, 1194, 1195, 1197, 1198, 1199 and c++-std-core postings number 17890 and 17912. Additional implementation experience, and subsequent changes to the core language have motivated the following changes and additions to the library specification.
A list of additional places in 23.3.2 Class template array that can exploit the constexpr language feature is below. For the changes listed, the new text is put in place in bold and green with the older text it is replacing struckthrough in red.
Proposed wording
a) Modify 23.3.2.1 [array.overview] as follows:
reference
operator[](size_type n);
constexpr const_reference
operator[](size_type n) const;
reference
at(size_type n);
constexpr const_reference
at(size_type n) const;
Peter asks: look at get, front/back, and data members too.
Acknowledgments
Many thanks to Jason Merrill, Paolo Carlini, and Jonathan Wakely for reviewing this document and providing assistance.