Despite feeling like I know *a lot* about how C++ works, I have to admit, I occasionally stumble upon features I never even knew were there.
Do you know all about C++ namespaces? I always thought that knowing about aliasing made me cool:
But I just stumbled upon selective namespace export:namespace OriginalName { void SomeFunction(); } namespace MyName=OriginalName; //...
MyName
::SomeFunction();
Who knew?using OriginalName::SomeFunction;
//...
SomeFunction()
;
Related: I keep meaning to write a post about my recent re-discovery of member pointers. While member method pointers are old hat, I can't remember the last time I've used pointers to simple members -- and yet, last week I needed them on two completely unrelated tasks.....
typedef SomeMemberType SomeClassType::*MemberPtr;
It gives you a way to select and pass around a specific member from a class, without needing an actual instance of that class. It's like using offsetof() but typesafe, and, once you get the typedef in place, much more readable.
At any rate... more on that later.
0 comments:
Post a Comment