C++ Logo

std-proposals

Advanced search

Re: [std-proposals] concept struct and concept integrals: allow concept preserving more types of results and extend conjunction/disjunction.

From: Bingzhi <bingzhi2025_at_[hidden]>
Date: Mon, 10 Aug 2026 22:10:02 +0800 (CST)
// Suppose you mean this:
template <class T> concept int C = 4112; // 0b1'0000'0001'0000

// Here's another concept int:
template <class T> concept int D = some_computing_1(^^T) && some_computing_2(^^T);
// Suppose some_computing_1(^^T) gives 0b0001 for integrals, 0b0010 for floating points.
// Suppose some_computing_2(^^T) gives 0b0001'0000 for member pointers, 0b0010'0000 for normal pointers.

template <class T> concept bool check_numbers_from_D = D<T> && 0b0011; // `concept bool` is Concepts TS syntax, and also allowing implicit conversion to bool (that is, allowing non boolean implicitly-convertible-to-bool value).

template <class T> requries check_numbers_from_D<T>
void do_something(T& t) { ... }

// How can `requires C<T> && D<T>` makes sense ? I can't give a reasonable idea.



At 2026-08-10 20:11:03, "Andre Kostur" <andre_at_[hidden]> wrote:

What does it mean for a concept to work out to be 4112? What does that look like when used in a requires clause?


On Mon, Aug 10, 2026 at 2:41 AM Bingzhi via Std-Proposals <std-proposals_at_[hidden]> wrote:

Computing via variable templates have slower compilation speed than that of concepts. But concepts only allows `concept bool`(see Concepts TS).
I want concept struct/integrals to be added.

Let Tp be:
a non-closure literal class type with the following properties:
    all base classes and non-static data members are public and non-mutable and
    the types of all base classes and non-static data members are structural types or (possibly multi-dimensional) array thereof;
an integral type;
an enumeration type.
Then I want `template <...> Tp concept name = ...;` to be valid and works just like a `concept bool`(or `concept` in Standard C++).

Further more, let the conjunction and disjunction of constraints be extended to bit & and bit | operations.
For conjunction, if one bit is 0, then all bits at the same position in the result of later constraint evaluations is ignored (that part is not computed if possible).
For disjunction, if one bit is 1, then all bits at the same position in the result of later constraint evaluations is ignored (that part is not computed if possible).
(That should be another proposal because it's a bit shocking.)

Same functionality but with slower compilation speed:
template <...> inline constexpr Tp name = ...;

If that concept structs and concept integrals (after the earlier `concept bool` in Concept TS) is not so conforming,
then, see my next idea: template final (or `final template`)
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]ocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-08-10 14:10:18