diff --git a/doc/topics/file_iteration.html b/doc/topics/file_iteration.html index 7bf70a16..6f381b46 100644 --- a/doc/topics/file_iteration.html +++ b/doc/topics/file_iteration.html @@ -197,6 +197,7 @@

#ifndef SAMPLE_H #define SAMPLE_H + #include <boost/config.hpp> // BOOST_HAS_PRAGMA_ONCE #include <boost/preprocessor/iteration/iterate.hpp> template<int> struct sample; @@ -204,6 +205,10 @@

#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 5, "sample.h")) ??=include BOOST_PP_ITERATE() + #ifndef BOOST_HAS_PRAGMA_ONCE + #pragma once + #endif + #endif // SAMPLE_H #else @@ -213,6 +218,17 @@

#endif +
+ Although not necessary for correctness, #pragma once is + added after BOOST_PP_ITERATE to trigger the multiple-include + optimization, allowing compilers to avoid subsequent includes of + "sample.h" to improve build speed. In this instance the the include guard + is not sufficient to trigger the multiple-include optimization as is it not + the first preprocessor directive occurring in the file. + #pragma once must occur after the last top-level + BOOST_PP_ITERATE(), after which "sample.h" will no longer + self-include. +
Using the same file like this raises another issue.  What happens when a file performs two separate file iterations over itself?  This is the @@ -227,6 +243,7 @@

#ifndef SAMPLE_H #define SAMPLE_H + #include <boost/config.hpp> // BOOST_HAS_PRAGMA_ONCE #include <boost/preprocessor/iteration/iterate.hpp> #include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor/repetition/enum_shifted_params.hpp> @@ -257,6 +274,10 @@

#define BOOST_PP_ITERATION_PARAMS_1 (4, (2, TYPELIST_MAX, "sample.h", 2)) ??=include BOOST_PP_ITERATE() + #ifndef BOOST_HAS_PRAGMA_ONCE + #pragma once + #endif + #endif // SAMPLE_H #elif BOOST_PP_ITERATION_FLAGS() == 1 @@ -331,6 +352,10 @@

#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, EXTRACT_MAX, "extract.h")) ??=include BOOST_PP_ITERATE() + #ifndef BOOST_HAS_PRAGMA_ONCE + #pragma once + #endif + #endif // EXTRACT_H #else @@ -460,6 +485,10 @@

#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 2, "file.h")) ??=include BOOST_PP_ITERATE() + #ifndef BOOST_HAS_PRAGMA_ONCE + #pragma once + #endif + #endif // FILE_H #elif BOOST_PP_ITERATION_DEPTH() == 1 @@ -666,6 +695,10 @@

??=include BOOST_PP_ITERATE() + #ifndef BOOST_HAS_PRAGMA_ONCE + #pragma once + #endif + #endif // FILE_H #else @@ -938,6 +971,10 @@

??=include BOOST_PP_INCLUDE_SELF() #endif + #ifndef BOOST_HAS_PRAGMA_ONCE + #pragma once + #endif + // iteration over cv-qualifiers #elif BOOST_PP_ITERATION_DEPTH() == 1 \ && BOOST_PP_ITERATION_FLAGS() == 1 \ diff --git a/test/iteration.h b/test/iteration.h index 035531aa..b05de82f 100644 --- a/test/iteration.h +++ b/test/iteration.h @@ -11,6 +11,8 @@ # # if !BOOST_PP_IS_ITERATING # +# include +# # include # include # include @@ -177,6 +179,10 @@ # # undef ITER50SA # +# ifndef BOOST_HAS_PRAGMA_ONCE +# pragma once +# endif +# # endif # # else