C++ Logo

std-proposals

Advanced search

Re: [std-proposals] New attribute to add implicit using statements for template parameter lists

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sun, 27 Nov 2022 22:03:29 -0500
On Sun, Nov 27, 2022 at 8:40 PM Ryan Klaus via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Let's say I have a template class that takes two enums:
>
> template <ColorComponents T_components, ColorComponentLayout T_layout>
> class Color { ... };
>
>
> Because I'm a good boy, each enum is of course an enum class like so:
>
> enum class ColorComponentLayout
> {
> _332,
> _4444,
> ...
> };
>
> enum class ColorComponents
> {
> RGB,
> RGBA,
> ARGB,
> ...
> };
>
>
> And all of the above is inside the namespace "ABC".
>
> In a just world, I feel like I should be able to right something like this:
>
> auto color = ABC::Color<RGBA, _8888>{};
>
>
> The compiler knows it wants a ColorComponents followed by a ColorComponentLayout, so all of the contextual information is theoretically there.

Template specialization is a thing. The parameters don't have to be
the ones in the primary template.

Received on 2022-11-28 03:05:32