BOOST_PP_INCLUDE_SELF

The BOOST_PP_INCLUDE_SELF macro includes a file indirectly.

#### Usage

#include BOOST_PP_INCLUDE_SELF()

#### Arguments

filename
  A quoted or angle-bracketed filename to be included by BOOST_PP_INCLUDE_SELF.

#### Remarks

BOOST_PP_INDIRECT_SELF must be defined prior to using this macro.
Most preprocessors will not allow a file to directly include itself--even when the file protects itself from such a scenario. This macro, in combination with BOOST_PP_INDIRECT_SELF allows a file to include itself indirectly.
While BOOST_PP_INDIRECT_SELF is being included, BOOST_PP_INCLUDE_SELF defines the macro BOOST_PP_IS_SELFISH to 1. When it returns from the inclusion, BOOST_PP_IS_SELFISH is undefined.

#### See Also

- BOOST_PP_INDIRECT_SELF
- BOOST_PP_IS_SELFISH

#### Requirements

Header: <boost/preprocessor/iteration/self.hpp>

#### Sample Code

    // 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

© Copyright Housemarque Oy 2002 © Copyright Paul Mensonides 2002

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)