I have not read Alexandrescu’s “Modern C++” entirely. The beginning is quite fascinating but as you go deeper you have strong feeling that you will never going need it or that someone will kill you for “template magic”. But... Currently I’m trying to write convenient API and found myself looking for useful tips inside “Modern C++”.
The trick above is about determining if ‘U’ is a pointer type or not. Code is based on common technique of using partially specialized templates - “struct is_pointr” is more concreate specialization so “struct is_pointer” will be used only in case of non pointer “U”. You can find that “is_pointer” is already part of boost’s type traits and std technical report 1, therefore code may be rewritten to shift responsibility for strange templates from you