C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Fwd: requires for non template classes

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Thu, 16 Apr 2026 22:58:09 +0200
On 4/16/26 22:45, Adrian via Std-Proposals wrote:
> i want to enforce this behavior on a class. Even if the class is unused,
> etc... so for that the only possible option right now is to
> use static_assert(HandlerController<Example>). I thought how about just
> writing:
>
> ```cc
>
> class Example
>
> requires(HandlerController<Example>)
>
> {};
>
> ```

So, the syntax choice is between the existing

class Example { ... };
static_assert(HandlerController<Example>);

and the novel

class Example
  requires (HandlerController<Example>)
{ ... };

Did I get this right? Are the semantics the same for
both cases? If no, please explain.

Call me opposed: rather fringe use-case with reasonably
expressive existing syntax.

Jens

Received on 2026-04-16 20:58:14