// file.h #if !BOOST_PP_IS_SELFISH #ifndef FILE_H_ #define FILE_H_ #include <boost/preprocessor/iteration/self.hpp> #define NAME X struct NAME { // ... #define BOOST_PP_INDIRECT_SELF "file.h" #include BOOST_PP_INCLUDE_SELF() }; #define NAME Y struct NAME { // ... #define BOOST_PP_INDIRECT_SELF "file.h" #include BOOST_PP_INCLUDE_SELF() }; #define NAME Z struct NAME { // ... #define BOOST_PP_INDIRECT_SELF "file.h" #include BOOST_PP_INCLUDE_SELF() }; #endif #else inline bool validate(NAME* p) { return true; } template<class T> bool validate(T* p) { return dynamic_cast<NAME*>(p); } #undef NAME #endif
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)