C++ Logo

std-proposals

Advanced search

[std-proposals] Mandates being allowed to use deleted functions to express the requirements

From: Halalaluyafail3 <luigighiron_at_[hidden]>
Date: Mon, 23 Mar 2026 20:34:01 -0400
N5032 Section 16.3.2.4 "Detailed specifications" [structure.specifications]
Paragraph 3:
> Mandates: the conditions that, if not met, render the program ill-formed.

Consider the following program:

#include<bit>
decltype(std::bit_cast<void*>(^^::))x;

Assume sizeof(void*)==sizeof(^^::) is true. Is this program ill-formed? It would
seem that is the case, but existing implementations do not reject this. The
example that follows the quoted text suggests that two possible implementations
of mandates are static_asserts and deleted overloads. For uses of mandates
outside of templates it seems like deleting the function is the only way to
implement the mandate. For uses of mandates inside of templates both options
would be valid, and create differences in the validity of programs such the
program above. Was it intended for both possibilities to be valid, or was it
intended for this program to assuredly be ill-formed or well-formed?

It seems like the uses of Mandates for the purposes of specifying deletion could
be split up into a new "Deleted When" element, if the intent was to require one
form be used. For example text_encoding uses mandates to require CHAR_BIT==8,
that could realistically only be implemented as a deleted overload. Would it
make sense to open a LWG issue for this?

Received on 2026-03-24 00:34:28