Skip to content

Commit

Permalink
gha / nodiscard
Browse files Browse the repository at this point in the history
  • Loading branch information
zajo committed Dec 10, 2023
1 parent 6b0f642 commit 1b2b46c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
19 changes: 10 additions & 9 deletions include/boost/leaf/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion include/boost/leaf/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace boost { namespace leaf {
class BOOST_LEAF_SYMBOL_VISIBLE error_id;

template <class T>
class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result;
class BOOST_LEAF_SYMBOL_VISIBLE result;

namespace leaf_detail
{
Expand Down
2 changes: 1 addition & 1 deletion include/boost/leaf/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ template <class... E>
#ifndef BOOST_LEAF_NO_EXCEPTIONS

template <class T>
class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result;
class BOOST_LEAF_SYMBOL_VISIBLE result;

namespace leaf_detail
{
Expand Down
6 changes: 3 additions & 3 deletions include/boost/leaf/handle_errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace boost { namespace leaf {

template <class T>
class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result;
class BOOST_LEAF_SYMBOL_VISIBLE result;

////////////////////////////////////////

Expand Down Expand Up @@ -829,7 +829,7 @@ try_handle_all( TryBlock && try_block, H && ... h ) noexcept
}

template <class TryBlock, class... H>
BOOST_LEAF_NODISCARD BOOST_LEAF_CONSTEXPR inline
BOOST_LEAF_ATTRIBUTE_NODISCARD BOOST_LEAF_CONSTEXPR inline
typename std::decay<decltype(std::declval<TryBlock>()())>::type
try_handle_some( TryBlock && try_block, H && ... h ) noexcept
{
Expand Down Expand Up @@ -923,7 +923,7 @@ try_handle_all( TryBlock && try_block, H && ... h )
}

template <class TryBlock, class... H>
BOOST_LEAF_NODISCARD inline
BOOST_LEAF_ATTRIBUTE_NODISCARD inline
typename std::decay<decltype(std::declval<TryBlock>()())>::type
try_handle_some( TryBlock && try_block, H && ... h )
{
Expand Down
2 changes: 1 addition & 1 deletion include/boost/leaf/on_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ namespace leaf_detail
}

template <class... Item>
BOOST_LEAF_NODISCARD BOOST_LEAF_CONSTEXPR inline
BOOST_LEAF_ATTRIBUTE_NODISCARD BOOST_LEAF_CONSTEXPR inline
leaf_detail::preloaded<typename leaf_detail::deduce_item_type<Item>::type...>
on_error( Item && ... i )
{
Expand Down
4 changes: 2 additions & 2 deletions include/boost/leaf/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace leaf_detail
////////////////////////////////////////

template <class T>
class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result
class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_ATTRIBUTE_NODISCARD result
{
template <class U>
friend class result;
Expand Down Expand Up @@ -607,7 +607,7 @@ namespace leaf_detail
}

template <>
class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_NODISCARD result<void>:
class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_ATTRIBUTE_NODISCARD result<void>:
result<leaf_detail::void_>
{
template <class U>
Expand Down

0 comments on commit 1b2b46c

Please sign in to comment.