diff --git a/include/boost/leaf/config.hpp b/include/boost/leaf/config.hpp index abf146fc..8b712512 100644 --- a/include/boost/leaf/config.hpp +++ b/include/boost/leaf/config.hpp @@ -209,17 +209,18 @@ //////////////////////////////////////// -#ifndef BOOST_LEAF_NODISCARD -# if defined(__has_cpp_attribute) -# if __has_cpp_attribute(nodiscard) -# if __cplusplus >= 201703L -# define BOOST_LEAF_NODISCARD [[nodiscard]] -# endif -# endif +#if defined(__has_attribute) && defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x5130) +# if __has_attribute(nodiscard) +# define BOOST_LEAF_ATTRIBUTE_NODISCARD [[nodiscard]] +# endif +#elif defined(__has_cpp_attribute) + //clang-6 accepts [[nodiscard]] with -std=c++14, but warns about it -pedantic +# if __has_cpp_attribute(nodiscard) && !(defined(__clang__) && (__cplusplus < 201703L)) && !(defined(__GNUC__) && (__cplusplus < 201100)) +# define BOOST_LEAF_ATTRIBUTE_NODISCARD [[nodiscard]] # endif #endif -#ifndef BOOST_LEAF_NODISCARD -# define BOOST_LEAF_NODISCARD +#ifndef BOOST_LEAF_ATTRIBUTE_NODISCARD +# define BOOST_LEAF_ATTRIBUTE_NODISCARD #endif //////////////////////////////////////// diff --git a/include/boost/leaf/error.hpp b/include/boost/leaf/error.hpp index 404f33ec..c845e6b0 100644 --- a/include/boost/leaf/error.hpp +++ b/include/boost/leaf/error.hpp @@ -71,7 +71,7 @@ namespace boost { namespace leaf { class BOOST_LEAF_SYMBOL_VISIBLE error_id; template -class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result; +class BOOST_LEAF_SYMBOL_VISIBLE result; namespace leaf_detail { diff --git a/include/boost/leaf/exception.hpp b/include/boost/leaf/exception.hpp index 2e74ccc3..dd2c71ef 100644 --- a/include/boost/leaf/exception.hpp +++ b/include/boost/leaf/exception.hpp @@ -223,7 +223,7 @@ template #ifndef BOOST_LEAF_NO_EXCEPTIONS template -class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result; +class BOOST_LEAF_SYMBOL_VISIBLE result; namespace leaf_detail { diff --git a/include/boost/leaf/handle_errors.hpp b/include/boost/leaf/handle_errors.hpp index 2aace214..f40cf8d9 100644 --- a/include/boost/leaf/handle_errors.hpp +++ b/include/boost/leaf/handle_errors.hpp @@ -12,7 +12,7 @@ namespace boost { namespace leaf { template -class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result; +class BOOST_LEAF_SYMBOL_VISIBLE result; //////////////////////////////////////// @@ -829,7 +829,7 @@ try_handle_all( TryBlock && try_block, H && ... h ) noexcept } template -BOOST_LEAF_NODISCARD BOOST_LEAF_CONSTEXPR inline +BOOST_LEAF_ATTRIBUTE_NODISCARD BOOST_LEAF_CONSTEXPR inline typename std::decay()())>::type try_handle_some( TryBlock && try_block, H && ... h ) noexcept { @@ -923,7 +923,7 @@ try_handle_all( TryBlock && try_block, H && ... h ) } template -BOOST_LEAF_NODISCARD inline +BOOST_LEAF_ATTRIBUTE_NODISCARD inline typename std::decay()())>::type try_handle_some( TryBlock && try_block, H && ... h ) { diff --git a/include/boost/leaf/on_error.hpp b/include/boost/leaf/on_error.hpp index 0144385d..2c5fde85 100644 --- a/include/boost/leaf/on_error.hpp +++ b/include/boost/leaf/on_error.hpp @@ -205,7 +205,7 @@ namespace leaf_detail } template -BOOST_LEAF_NODISCARD BOOST_LEAF_CONSTEXPR inline +BOOST_LEAF_ATTRIBUTE_NODISCARD BOOST_LEAF_CONSTEXPR inline leaf_detail::preloaded::type...> on_error( Item && ... i ) { diff --git a/include/boost/leaf/result.hpp b/include/boost/leaf/result.hpp index ea63aa4d..9835e066 100644 --- a/include/boost/leaf/result.hpp +++ b/include/boost/leaf/result.hpp @@ -174,7 +174,7 @@ namespace leaf_detail //////////////////////////////////////// template -class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result +class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_ATTRIBUTE_NODISCARD result { template friend class result; @@ -607,7 +607,7 @@ namespace leaf_detail } template <> -class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result: +class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_ATTRIBUTE_NODISCARD result: result { template