[libcxx-commits] [libcxx] [libc++] add floating point type check for uniform real distrubtion (PR #70564)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 23 12:38:47 PST 2023
================
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<_RealType = double>
+// class uniform_real_distribution;
+
+// result_type must be floating type, int type is unsupported
+
+#include <random>
+
+struct test_random : public std::uniform_real_distribution<int> {};
+
+// expected-error@*:* {{static assertion failed due to requirement 'is_floating_point<int>::value': result_type must be floating type}}
----------------
mordante wrote:
```suggestion
// expected-error@*:* {{static assertion failed due to requirement 'is_floating_point<int>::value': result_type must be floating type}}
struct test_random : public std::uniform_real_distribution<int> {};
```
This is the typical way we write these validation types. Maybe add a few more invalid types.
https://github.com/llvm/llvm-project/pull/70564
More information about the libcxx-commits
mailing list