Date: Thu, 16 Apr 2026 22:06:51 +0200
I want my concept to provide the same security as an virtual class. I
want to ensure the code fails at the compilation of the class. In this
specific use case the class has no need to have any templates. So the
requires would enforce the concept on the class catching mistakes made
by users or ever rough AI bots. I do not know if this is the cleanest
approach to the problem! But the only other way to archive the same
behavior was through a static_assert. I am not a big fan of
static_assert and to my understanding the c++ community has started to
make a push away from it.
On 4/16/26 21:44, Andre Kostur wrote:
> Perhaps if you had an example of what you’d like to do? If it’s
> non-template code, then all of the types are known so there doesn’t
> seem to be anything to constrain.
>
> On Thu, Apr 16, 2026 at 12:41 PM Adrian via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
> Hello everyone,
>
>
> templates in c++ offer a great way to modularize your codebase
> without a sacrificing on compile time speed. My Proposal is
> relatively simple. Requires should also work on non template
> classes without the need to do an static assert. I think this
> would be more suiting in the context of modern c++, while
> providing consistent code style. I know right now that is also
> possible by using a placeholder template! But this a very ugly in
> my opinion, since a template always insinuates that something
> needs to be provided.
>
> Thank you everybody for reading my little proposal. Please correct
> me, if this was already discussed or not possible due to language
> limitation, etc... . I am relatively new to c++ and therefor still
> exploring the limits of the language.
>
>
> Best regards
>
> Adrian
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
want to ensure the code fails at the compilation of the class. In this
specific use case the class has no need to have any templates. So the
requires would enforce the concept on the class catching mistakes made
by users or ever rough AI bots. I do not know if this is the cleanest
approach to the problem! But the only other way to archive the same
behavior was through a static_assert. I am not a big fan of
static_assert and to my understanding the c++ community has started to
make a push away from it.
On 4/16/26 21:44, Andre Kostur wrote:
> Perhaps if you had an example of what you’d like to do? If it’s
> non-template code, then all of the types are known so there doesn’t
> seem to be anything to constrain.
>
> On Thu, Apr 16, 2026 at 12:41 PM Adrian via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
> Hello everyone,
>
>
> templates in c++ offer a great way to modularize your codebase
> without a sacrificing on compile time speed. My Proposal is
> relatively simple. Requires should also work on non template
> classes without the need to do an static assert. I think this
> would be more suiting in the context of modern c++, while
> providing consistent code style. I know right now that is also
> possible by using a placeholder template! But this a very ugly in
> my opinion, since a template always insinuates that something
> needs to be provided.
>
> Thank you everybody for reading my little proposal. Please correct
> me, if this was already discussed or not possible due to language
> limitation, etc... . I am relatively new to c++ and therefor still
> exploring the limits of the language.
>
>
> Best regards
>
> Adrian
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2026-04-16 20:08:03
