Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the [[nodiscard]] attribute to the result class #72

Merged
merged 8 commits into from
Jul 29, 2024
6 changes: 3 additions & 3 deletions include/boost/leaf/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@
# 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))
// require c++17 regardless of compiler
# if __has_cpp_attribute(nodiscard) && __cplusplus >= 201703L
# define BOOST_LEAF_ATTRIBUTE_NODISCARD [[nodiscard]]
# endif
#endif
Expand Down Expand Up @@ -257,7 +257,7 @@
////////////////////////////////////////

#ifdef __GNUC__
# define BOOST_LEAF_SYMBOL_VISIBLE __attribute__((__visibility__("default")))
# define BOOST_LEAF_SYMBOL_VISIBLE [[gnu::visibility("default")]]
#else
# define BOOST_LEAF_SYMBOL_VISIBLE
#endif
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 result
class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_ATTRIBUTE_NODISCARD result
{
template <class U>
friend class result;
Expand Down Expand Up @@ -620,7 +620,7 @@ namespace leaf_detail
}

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