[gcc r12-5623] libstdc++: Add [[nodiscard]] to std::byteswap

Jakub Jelinek jakub@gcc.gnu.org
Tue Nov 30 12:33:35 GMT 2021


https://gcc.gnu.org/g:92084a6dcda8aaee538b4512bbaf161e1155a296

commit r12-5623-g92084a6dcda8aaee538b4512bbaf161e1155a296
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 30 13:30:27 2021 +0100

    libstdc++: Add [[nodiscard]] to std::byteswap
    
    This patch adds [[nodiscard]] to std::byteswap, because the function
    template doesn't do anything useful if the result isn't used.
    
    2021-11-30  Jakub Jelinek  <jakub@redhat.com>
    
            * include/std/bit (byteswap): Add [[nodiscard]].

Diff:
---
 libstdc++-v3/include/std/bit | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit
index 18ce5ca220c..4facb615014 100644
--- a/libstdc++-v3/include/std/bit
+++ b/libstdc++-v3/include/std/bit
@@ -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
     {


More information about the Libstdc++-cvs mailing list