Zero Initialize a Type

91 Views Asked by At

Given a variable of an unsigned integral type: foo lets say I want to do this:

const decltype<foo> bar{};

cout << (55834574890LL & ~bar) << endl;

That gives me the expected 42. But now let's say that I want to do away with the bar variable. So something like this:

cout << (55834574890LL & ~decltype<foo>{}) << endl;

But I just get an error:

error: expected primary-expression before decltype

I've also tried declval but that returns a reference, which is also no good. Is there a way I can do this?

1

There are 1 best solutions below

0
On BEST ANSWER

You should use round brackets:

auto v = 55834574890LL & ~decltype(foo){};

Here's a demo.