Document number: P0510R0
Project: Programming Language C++
Audience: Library Working Group
 
Erich Keane <erich.keane@intel.com>
 
Date: 2016-11-10

Disallowing references, incomplete types, arrays, and empty variants

I. Introduction and Motivation

National Body Comments [P0488R0] US112, US115, US116, US117, US120, US181, FI22, CH3 (the second), CH4, CH5, CH6, and CH8 point out issues with having variant permit empty parameter packs, void parameters, arrays, and reference parameters. Library Evolution Working Group decided to disallow these four conditions.

II. Impact on the Standard

This proposal alters the wording for variant, limiting its scope. Implementers with existing implementations would be required to modify their implementation to disallow references, incomplete types, and empty variants.

III. Proposed wording relative to the Working Draft N4606.

Note for editor: The following changes apply to 20.7.2[variant.variant]:

¶2: All types in Types... shall be (possibly cv-qualified) object types that are not arrays , (possibly cv-qualified) void, or references. [ Note: Implementations could decide to store references in a wrapper. — end note ]
¶3: A program that instantiates the definition of variant with no template arguments is ill-formed.

Note for editor: The following changes apply to 20.7.4[variant.get]:

¶3:Requires:I < sizeof...(Types), and TI is not (possibly cv-qualified) void. Otherwise the program is ill-formed.
¶5:Requires: The type T occurs exactly once in Types..., and T is not (possibly cv-qualified) void. Otherwise, the program is ill-formed.
¶7:Requires:I < sizeof...(Types), and TI is not (possibly cv-qualified) void. Otherwise the program is ill-formed.
¶9:Requires: The type T occurs exactly once in Types..., and T is not (possibly cv-qualified) void. Otherwise, the program is ill-formed.

IV. Revision History

Revision 0:

V. References

[N4606] C++17 CD Ballot Document. Available online at www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4606.pdf.

[P0488R0] National Body Comments Available online at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0488r0.pdf.