user13286774
user13286774

Reputation:

C++ Declaring a variable with the ternary operator

I was wondering if it's possible to do something like this. (i know it's really weird ^^)

bool B(true);
std::vector< (B == true) ? bool : int > v;

Upvotes: 1

Views: 222

Answers (1)

Oliv
Oliv

Reputation: 18041

constexpr bool B(true);
std::vector< std::conditional_t <B == true, bool , int >> v;

Upvotes: 4

Related Questions