libstdc++: Add [[nodiscard]] to std::byteswap
Commit Message
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]].
Jakub
Comments
On Tue, 30 Nov 2021 at 08:58, Jakub Jelinek via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> 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?
Yes, thanks.
@@ -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
{