C++ Logo

std-proposals

Advanced search

Re: "Union types" syntactic sugar

From: Michał Piotr Gawron <mcvsama_at_[hidden]>
Date: Wed, 4 Mar 2020 15:12:20 +0100
On 04.03.2020 15:03, Михаил Найденов wrote:
> Well,
>
> template<class T>
> concept charOrUInt8 = std::is_same_v<char> || std::is_same_v<uint8_t>;
>
> void f (charOrUInt8 auto x);
>
> template<charOrUInt8 T>
> void f (std::basic_string<T> x)
>
> Close enough, if ask me :)

That still requires writing a series of std::is_same_v<> but this time
I'd also have to invent a name for the concept. I'd like to avoid that
and keep the actual list of types right in the arguments list. Of
course, if I wanted to reuse the allowed types list, I'd use a concept.

-- 
Michał Gawron
mcv.mulabs.org

Received on 2020-03-04 08:15:07