From e22bd49fa717f065491058fb4b50a6ffbee4532f Mon Sep 17 00:00:00 2001 From: Braden Ganetsky Date: Thu, 11 Jul 2024 17:02:21 -0500 Subject: [PATCH] Fix MSVC issue with deriving from empty_value --- include/boost/core/empty_value.hpp | 54 +++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/include/boost/core/empty_value.hpp b/include/boost/core/empty_value.hpp index d8ffa30..ee86810 100644 --- a/include/boost/core/empty_value.hpp +++ b/include/boost/core/empty_value.hpp @@ -95,9 +95,53 @@ private: }; #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +#if defined(BOOST_MSVC) +namespace detail { + +template +class empty_value_base + : public T { +public: +#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) + empty_value_base() = default; +#else + BOOST_CONSTEXPR empty_value_base() { } +#endif + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + template + BOOST_CONSTEXPR empty_value_base(U&& value, Args&&... args) + : T(std::forward(value), std::forward(args)...) { } +#else + template + BOOST_CONSTEXPR empty_value_base(U&& value) + : T(std::forward(value)) { } +#endif +#else + template + BOOST_CONSTEXPR empty_value_base(const U& value) + : T(value) { } + + template + BOOST_CONSTEXPR empty_value_base(U& value) + : T(value) { } +#endif +}; + +} /* detail */ +#endif + template class empty_value +#if defined(BOOST_MSVC) + : detail::empty_value_base { + typedef detail::empty_value_base base; +#else : T { + typedef T base; +#endif + public: typedef T type; @@ -108,26 +152,26 @@ public: #endif BOOST_CONSTEXPR empty_value(boost::empty_init_t) - : T() { } + : base() { } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value, Args&&... args) - : T(std::forward(value), std::forward(args)...) { } + : base(std::forward(value), std::forward(args)...) { } #else template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value) - : T(std::forward(value)) { } + : base(std::forward(value)) { } #endif #else template BOOST_CONSTEXPR empty_value(boost::empty_init_t, const U& value) - : T(value) { } + : base(value) { } template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U& value) - : T(value) { } + : base(value) { } #endif BOOST_CONSTEXPR const T& get() const BOOST_NOEXCEPT {