diff mbox series

libstdc++: Add [[nodiscard]] to std::byteswap

Message ID 20211130085652.GK2646553@tucnak
State Committed
Headers show
Series libstdc++: Add [[nodiscard]] to std::byteswap | expand

Commit Message

Jakub Jelinek Nov. 30, 2021, 8:56 a.m. UTC
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

Jonathan Wakely Nov. 30, 2021, 10:41 a.m. UTC | #1
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.
diff mbox series

Patch

--- 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
     {