diff --git a/include/boost/foreach.hpp b/include/boost/foreach.hpp index eb3a50b6..e712c5c0 100644 --- a/include/boost/foreach.hpp +++ b/include/boost/foreach.hpp @@ -92,6 +92,15 @@ # include #endif +// workaround for name clash with qt's foreach +#if defined(BOOST_MSVC) || defined(BOOST_CLANG) || defined(BOOST_GCC) +# ifdef foreach +# define BOOST_QFOREACH_WORKAROUND +# pragma push_macro("foreach") +# endif +#endif + + namespace boost { @@ -1124,4 +1133,11 @@ rderef(auto_any_t cur, type2type *) if (boost::foreach_detail_::set_false(BOOST_FOREACH_ID(_foreach_continue))) {} else \ for (VAR = BOOST_FOREACH_RDEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true) +#if defined(BOOST_MSVC) || defined(BOOST_CLANG) || defined(BOOST_GCC) +# ifdef BOOST_QFOREACH_WORKAROUND +# undef BOOST_QFOREACH_WORKAROUND +# pragma pop_macro("foreach") +# endif +#endif + #endif diff --git a/include/boost/foreach_fwd.hpp b/include/boost/foreach_fwd.hpp index 4e0bb370..97abe536 100644 --- a/include/boost/foreach_fwd.hpp +++ b/include/boost/foreach_fwd.hpp @@ -14,6 +14,14 @@ #ifndef BOOST_FOREACH_FWD_HPP #define BOOST_FOREACH_FWD_HPP +// workaround for name clash with qt's foreach +#if defined(BOOST_MSVC) || defined(BOOST_CLANG) || defined(BOOST_GCC) +# ifdef foreach +# define BOOST_QFOREACH_WORKAROUND +# pragma push_macro("foreach") +# endif +#endif + // This must be at global scope, hence the uglified name enum boost_foreach_argument_dependent_lookup_hack { @@ -48,4 +56,11 @@ namespace foreach } // namespace boost +#if defined(BOOST_MSVC) || defined(BOOST_CLANG) || defined(BOOST_GCC) +# ifdef BOOST_QFOREACH_WORKAROUND +# undef BOOST_QFOREACH_WORKAROUND +# pragma pop_macro("foreach") +# endif +#endif + #endif