(Click here for a personal note from Marshall Cline.)
C++ FAQ
/
Section 26
/ FAQ 26.12
Section 26:
26.1
Can
sizeof(char)
be 2 on some machines? For example, what about double-byte characters?
26.2
What are the units of
sizeof
?
26.3
Whoa, but what about machines or compilers that support multibyte characters. Are you saying that a "character" and a
char
might be different?!?
26.4
But, but, but what about machines where a
char
has more than 8 bits? Surely you're not saying a C++ byte might have more than 8 bits, are you?!?
26.5
Okay, I could imagine a machine with 9-bit bytes. But surely not 16-bit bytes or 32-bit bytes, right?
26.6
I'm sooooo confused. Would you please go over the rules about bytes,
char
s, and characters one more time?
26.7
What is a "POD type"?
26.8
When initializing non-static data members of built-in / intrinsic / primitive types, should I use the "initialization list" or assignment?
26.9
When initializing static data members of built-in / intrinsic / primitive types, should I worry about the "
static
initialization order fiasco"?
26.10
Can I define an operator overload that works with built-in / intrinsic / primitive types?
26.11
When I
delete
an array of some built-in / intrinsic / primitive type, why can't I just say
delete a
instead of
delete[] a
?
26.12
How can I tell if an integer is a power of two without looping?
26.13
What should be returned from a function?
[26.12] How can I tell if an integer is a power of two without looping?
inline bool isPowerOf2(int i) { return i > 0 && (i & (i - 1)) == 0; }