[PATCH] libstdc++: Add [[nodiscard]] to std::byteswap
Jakub Jelinek
jakub@redhat.com
Tue Nov 30 08:56:52 GMT 2021
Hi!
This patch adds [[nodiscard]] to std::byteswap, because the function
template doesn't do anything useful if the result isn't used.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2021-11-30 Jakub Jelinek <jakub@redhat.com>
* include/std/bit (byteswap): Add [[nodiscard]].
--- libstdc++-v3/include/std/bit.jj 2021-11-28 16:32:15.204524854 +0100
+++ libstdc++-v3/include/std/bit 2021-11-29 17:40:00.781074520 +0100
@@ -83,6 +83,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Reverse order of bytes in the object representation of `value`.
template<typename _Tp>
+ [[nodiscard]]
constexpr enable_if_t<is_integral<_Tp>::value, _Tp>
byteswap(_Tp __value) noexcept
{
Jakub
More information about the Gcc-patches
mailing list