C++ Logo

std-proposals

Advanced search

Re: [std-proposals] if () {typedef x y;}

From: Wilhelm M <wilhelm.now_at_[hidden]>
Date: Sun, 1 May 2022 10:34:01 +0200
Isn't this std::conditional?


typedef std::conditional<cond, int, double> type;

https://en.cppreference.com/w/cpp/types/conditional

On Sun, May 1, 2022, 10:30 Abdullah Qasim via Std-Proposals <
std-proposals_at_[hidden]> wrote:

>
>
> if (cond) {
>
> typedef int type;
>
> } else {
>
> typedef double type;
>
> }
>
> type x;
>
>
>
>
>
> This is useful in many ways, as one can check for cond ni one place,
> rather than use global variables, & check 27 times...
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2022-05-01 08:34:13