[libcxx-commits] [PATCH] D138212: [libc++] Use numeric_limits instead of raw INT_MAX

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 18 08:32:25 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGeaa4f041f786: [libc++] Use numeric_limits instead of raw INT_MAX (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138212/new/

https://reviews.llvm.org/D138212

Files:
  libcxx/include/__random/discard_block_engine.h
  libcxx/include/random
  libcxx/test/libcxx/transitive_includes/cxx2b.csv


Index: libcxx/test/libcxx/transitive_includes/cxx2b.csv
===================================================================
--- libcxx/test/libcxx/transitive_includes/cxx2b.csv
+++ libcxx/test/libcxx/transitive_includes/cxx2b.csv
@@ -502,7 +502,6 @@
 queue vector
 queue version
 random bit
-random climits
 random cmath
 random cstddef
 random cstdint
Index: libcxx/include/random
===================================================================
--- libcxx/include/random
+++ libcxx/include/random
@@ -1729,6 +1729,7 @@
 
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <algorithm>
+#  include <climits>
 #  include <cmath>
 #  include <concepts>
 #  include <cstddef>
Index: libcxx/include/__random/discard_block_engine.h
===================================================================
--- libcxx/include/__random/discard_block_engine.h
+++ libcxx/include/__random/discard_block_engine.h
@@ -12,8 +12,8 @@
 #include <__config>
 #include <__random/is_seed_sequence.h>
 #include <__utility/move.h>
-#include <climits>
 #include <iosfwd>
+#include <limits>
 #include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -33,7 +33,9 @@
 
     static_assert(  0 <  __r, "discard_block_engine invalid parameters");
     static_assert(__r <= __p, "discard_block_engine invalid parameters");
-    static_assert(__r <= INT_MAX, "discard_block_engine invalid parameters");
+#ifndef _LIBCPP_CXX03_LANG // numeric_limits::max() is not constexpr in C++03
+    static_assert(__r <= numeric_limits<int>::max(), "discard_block_engine invalid parameters");
+#endif
 public:
     // types
     typedef typename _Engine::result_type result_type;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138212.476492.patch
Type: text/x-patch
Size: 1692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221118/c76f2b25/attachment.bin>


More information about the libcxx-commits mailing list