0

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?

Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288

1 Answers1

2

You should use round brackets:

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

Here's a demo.

joe_chip
  • 2,468
  • 1
  • 12
  • 23