From 790d4f729fb8f64d1fd31207c93b81f4be221753 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Thu, 4 Jan 2024 02:03:33 +0100 Subject: [PATCH] cleaner workaround for VS2017 launder bug --- .../boost/optional/detail/optional_aligned_storage.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/boost/optional/detail/optional_aligned_storage.hpp b/include/boost/optional/detail/optional_aligned_storage.hpp index 6f27e17..147c614 100644 --- a/include/boost/optional/detail/optional_aligned_storage.hpp +++ b/include/boost/optional/detail/optional_aligned_storage.hpp @@ -60,12 +60,14 @@ class aligned_storage T * ptr_ref() { return static_cast (address()); } #endif -#ifndef BOOST_MSVC // workaround for MSVC 14.1 compiler crash - T const& ref() const { return *boost::core::launder(ptr_ref()); } - T & ref() { return *boost::core::launder(ptr_ref()); } -#else +#if BOOST_WORKAROUND(BOOST_MSVC, < 1920) + // workaround for VS2017 (32 bit) compiler crash + // toolset=msvc-14.1 cxxstd=17 variant=release address-model=32 T const& ref() const { return *ptr_ref(); } T & ref() { return *ptr_ref(); } +#else + T const& ref() const { return *boost::core::launder(ptr_ref()); } + T & ref() { return *boost::core::launder(ptr_ref()); } #endif } ;