Trying to get back into C++ after only using python for almost a year. I ran into this one while trying out partial template specialization, narrowed it down to this simple test case...
structs can have functions?
Yes. In C++, the only difference between a struct and a function is that a struct's members are public by default, if I recall right.
...ugh, should've googled more first. Apparently it's two-phase name lookup that makes it barf.
Templates and accessing inherited members
Isn't partial specialization the sort of thing that you should only whip out if your execution time and/or cache profilers tell you that yeah, maybe using a 32-bit integer for a boolean value wasn't that smart after all?
Plus, structs have different alignment rules. I seem to recall that classes' members may be even reordered to get better packing in the presence of alignment constraints, whereas structs need to appear in memory as they are declared.
>>Plus, structs have different alignment rules. I seem to recall that classes' members may be even reordered
9.2.12 Nonstatic data members of a (non-union) class declared without an intervening access-specifier are allocated so that
I thought operator overloading could only overload... operators. Can you really overload typecasts as if they're operators? I've never heard or seen that. If it's true, then I've said it before and I've said it again -- it's pretty much guaranteed I learn something new about C++ every week, for almost like 7 years now. Just last year I found out C++ has try/catch/throw style exceptions... I don't use them (I can only take so much visual clutter), but they're there if I want to.
Heh, yeah, C++ always has some new stuff, especially the obscure template magic you only tend to see in things like boost.
I have this in my vector class:
dicks out for Harambe