C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Named, composable type sets for concept constraints

From: Emanuel Spiridon <spiridonemanuel23_at_[hidden]>
Date: Wed, 25 Mar 2026 02:33:48 +0200
Since the last time I was sent a reply regarding this proposal, I have
written a draft paper to submit. I will send it here first in hope for
mistakes I didn't catch, may they be grammatical or logical.

Thank you for the feedback I got. Here's a draft of the paper written in Google
Docs
<https://docs.google.com/document/d/11VuyfAqOIC_FOcG9TrgKQfJdRYqy1D8snGV2lyvuwvM/edit?usp=sharing>,
and of course, a link to the GitHub implementation
<https://github.com/progress-3325/tagging>.

On Sat, 14 Mar 2026 at 13:13, Emanuel Spiridon <spiridonemanuel23_at_[hidden]>
wrote:
> C++ currently has no way to create a named and reusable set of types that
can be used as a concept constraint. Every time you write a concept
constraint or requires section, you must enumerate the types, which makes
large constraints unreadable and unmaintainable.
>
> I propose a solution, a type with template arguments for any type,
including user-defined types and standard library types, which you can then
use when creating a concept or requires section, by stating the named type
list and the type you want to check.
>
> Here is how my implementation works:

> template<typename T>
> requires std::is_same_v<T, unsigned char> || std::is_same_v<T, unsigned short> || std::is_same_v<T, unsigned int> || std::is_same_v<T, unsigned long> || std::is_same_v<T, unsigned long long>> void natural_only(T);> template<typename T>
> requires std::is_same_v<T, unsigned char> || std::is_same_v<T, unsigned short> || std::is_same_v<T, unsigned int> || std::is_same_v<T, unsigned long> || std::is_same_v<T, unsigned long long> || std::is_same_v<T, char> || std::is_same_v<T, short> || std::is_same_v<T, int> || std::is_same_v<T, long> || std::is_same_v<T, long long>> void whole_only(T);
>> using natural_numbers = typename tag::merge_tags_and_types<unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long>::type;> using whole_numbers = typename tag::merge_tags_and_types<signed char, short, int, long, long long, natural_numbers>::type;> using real_numbers = typename tag::merge_tags_and_types<float, double, long double>::type;> using numbers = typename tag::merge_tags_and_types<whole_numbers, real_numbers>::type;
>> template<typename T>> concept is_number = tag::contains<numbers, T>;
> > template<typename T>> concept is_whole = tag::contains<whole_numbers, T>;
> > template<typename T>> concept is_natural = tag::contains<natural_numbers, T>;
> > template<typename T>> concept is_real = tag::contains<real_numbers, T>;
> > template<typename T>
> requires tag::contains<natural_numbers, T>> void natural_only(T);
>
>
> You can read the source of the implementation at Github <https://github.com/progress-3325/tagging>. A paper draft is forthcoming
>
> I am looking for feedback before submitting a formal paper.

Received on 2026-03-25 00:34:02