public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Improve comment on _Power_of_2 helper function
@ 2020-11-09 14:55 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2020-11-09 14:55 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 180 bytes --]

libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (__detail::_Power_of_2):
	Document that true result for zero is intentional.

Tested x86_64-linux. Committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1025 bytes --]

commit b2b85163731e8647542f2f7561bd4c69ae5f5f2a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Nov 9 14:32:45 2020

    libstdc++: Improve comment on _Power_of_2 helper function
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/uniform_int_dist.h (__detail::_Power_of_2):
            Document that true result for zero is intentional.

diff --git a/libstdc++-v3/include/bits/uniform_int_dist.h b/libstdc++-v3/include/bits/uniform_int_dist.h
index 8f02b85c9bb0..4169f705c2af 100644
--- a/libstdc++-v3/include/bits/uniform_int_dist.h
+++ b/libstdc++-v3/include/bits/uniform_int_dist.h
@@ -56,7 +56,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   namespace __detail
   {
-    /* Determine whether number is a power of 2.  */
+    // Determine whether number is a power of two.
+    // This is true for zero, which is OK because we want _Power_of_2(n+1)
+    // to be true if n==numeric_limits<_Tp>::max() and so n+1 wraps around.
     template<typename _Tp>
       constexpr bool
       _Power_of_2(_Tp __x)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-09 14:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 14:55 [committed] libstdc++: Improve comment on _Power_of_2 helper function Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).