От: | eao197 | http://eao197.blogspot.com | |
Дата: | 02.10.07 05:17 | ||
Оценка: | 1 (1) |
Summary
The need to write efficient and high-performance programs in C++ make it desirable to be able to manipulate bits and groups of bits easily, efficiently, and safely. C++ provides out-of-the-box tools to accomplish the first two goals with its bitwise operations, but it does so at the expense of the third objective, safety.
This article presents a solution to the problem of constraining bit operations to allow only safe and legitimate ones, and turn all invalid bit manipulations into compile-time errors. Best of all, the syntax of bit operations remains unchanged, and the code working with bits does not need to be modified, except possibly to fix errors that had as yet remained undetected.