Кресты / Говнокод #29056 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
#include <iostream>

union is_odd {
  long long int number;
  bool yes : sizeof(long long int);
};

int main() {
  std::boolalpha(std::cout);
  for (long long int i = -10; i < 10; ++i) {
    std::cout << i << " is odd? "
              << is_odd{ .number = i }.yes
              << "\n";
  }
}

DEMO:
https://godbolt.org/z/5exc84eYK

Запостил: shittycode43 shittycode43, (Updated )

Комментарии (2) RSS

  • Actually I just realized that the size of bitfield doesn't even matter, the bitfield size in this code isn't even correct either
    Ответить

Добавить комментарий

Семь раз отмерь — один отрежь, guest!

    А не использовать ли нам bbcode?


    8