diff --git a/include/boost/unordered/detail/foa/core.hpp b/include/boost/unordered/detail/foa/core.hpp index 9358e52b..c4fb08f4 100644 --- a/include/boost/unordered/detail/foa/core.hpp +++ b/include/boost/unordered/detail/foa/core.hpp @@ -991,41 +991,6 @@ _STL_RESTORE_DEPRECATED_WARNING #pragma warning(pop) #endif -#if defined(BOOST_GCC) -/* GCC's -Wshadow triggers at scenarios like this: - * - * struct foo{}; - * template - * struct derived:Base - * { - * void f(){int foo;} - * }; - * - * derivedx; - * x.f(); // declaration of "foo" in derived::f shadows base type "foo" - * - * This makes shadowing warnings unavoidable in general when a class template - * derives from user-provided classes, as is the case with table_core and - * empty_value's below. - */ - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" -#endif - -#if defined(BOOST_MSVC) -#pragma warning(push) -#pragma warning(disable:4714) /* marked as __forceinline not inlined */ -#endif - -#if BOOST_WORKAROUND(BOOST_MSVC,<=1900) -/* VS2015 marks as unreachable generic catch clauses around non-throwing - * code. - */ -#pragma warning(push) -#pragma warning(disable:4702) -#endif - /* We expose the hard-coded max load factor so that tests can use it without * needing to pull it from an instantiated class template such as the table * class. @@ -1084,6 +1049,21 @@ struct try_emplace_args_t{}; * the element_type itself is moved. */ +#include + +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4714) /* marked as __forceinline not inlined */ +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC,<=1900) +/* VS2015 marks as unreachable generic catch clauses around non-throwing + * code. + */ +#pragma warning(push) +#pragma warning(disable:4702) +#endif + template class @@ -1878,9 +1858,7 @@ private: #pragma warning(pop) /* C4714 */ #endif -#if defined(BOOST_GCC) -#pragma GCC diagnostic pop /* ignored "-Wshadow" */ -#endif +#include } /* namespace foa */ } /* namespace detail */ diff --git a/include/boost/unordered/detail/foa/ignore_wshadow.hpp b/include/boost/unordered/detail/foa/ignore_wshadow.hpp new file mode 100644 index 00000000..f84262bc --- /dev/null +++ b/include/boost/unordered/detail/foa/ignore_wshadow.hpp @@ -0,0 +1,35 @@ +/* Copyright 2023 Joaquin M Lopez Munoz. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * See https://www.boost.org/libs/unordered for library home page. + */ + +#include + +#if defined(BOOST_GCC) +#if !defined(BOOST_UNORDERED_DETAIL_RESTORE_WSHADOW) + /* GCC's -Wshadow triggers at scenarios like this: + * + * struct foo{}; + * template + * struct derived:Base + * { + * void f(){int foo;} + * }; + * + * derivedx; + * x.f(); // declaration of "foo" in derived::f shadows base type "foo" + * + * This makes shadowing warnings unavoidable in general when a class template + * derives from user-provided classes, as is the case with foa::table_core + * deriving from empty_value. + */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#else +#pragma GCC diagnostic pop +#endif +#endif diff --git a/include/boost/unordered/detail/foa/restore_wshadow.hpp b/include/boost/unordered/detail/foa/restore_wshadow.hpp new file mode 100644 index 00000000..89c32c23 --- /dev/null +++ b/include/boost/unordered/detail/foa/restore_wshadow.hpp @@ -0,0 +1,11 @@ +/* Copyright 2023 Joaquin M Lopez Munoz. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * See https://www.boost.org/libs/unordered for library home page. + */ + +#define BOOST_UNORDERED_DETAIL_RESTORE_WSHADOW +#include +#undef BOOST_UNORDERED_DETAIL_RESTORE_WSHADOW diff --git a/include/boost/unordered/detail/foa/table.hpp b/include/boost/unordered/detail/foa/table.hpp index 6fa48515..fb958076 100644 --- a/include/boost/unordered/detail/foa/table.hpp +++ b/include/boost/unordered/detail/foa/table.hpp @@ -205,6 +205,8 @@ union uninitialized_storage * boost::unordered_[flat|node]_[map|set]. */ +#include + template class table:table_core { @@ -504,6 +506,8 @@ private: } }; +#include + } /* namespace foa */ } /* namespace detail */ } /* namespace unordered */