static assert that template typename T is NOT complete?
问题 Is there a way to static_assert that a type T is Not complete at that point in a header? The idea is to have a compile error if someone adds #includes down the road in places they should not be. related: How to write `is_complete` template? Using that link's answer, namespace { template<class T, int discriminator> struct is_complete { static T & getT(); static char (& pass(T))[2]; static char pass(...); static const bool value = sizeof(pass(getT()))==2; }; } #define IS_COMPLETE(X) is_complete