[libcxx-commits] [libcxx] Check floating type for uniform distribution (PR #70562)
Nhat Nguyen via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Oct 28 11:12:13 PDT 2023
https://github.com/NhatNguyen1810 created https://github.com/llvm/llvm-project/pull/70562
None
>From 477dd014e50ddcd6c7e118b46891f2c5cd409eec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= <“nhat7203 at gmail.com”>
Date: Sat, 28 Oct 2023 13:58:28 -0400
Subject: [PATCH 1/3] add static assert to check for floating type
---
libcxx/include/__random/uniform_real_distribution.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/__random/uniform_real_distribution.h b/libcxx/include/__random/uniform_real_distribution.h
index 1388cef95f39414..8514f734a4d75b4 100644
--- a/libcxx/include/__random/uniform_real_distribution.h
+++ b/libcxx/include/__random/uniform_real_distribution.h
@@ -27,10 +27,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _RealType = double>
class _LIBCPP_TEMPLATE_VIS uniform_real_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value, "result_type must be of type floating point");
public:
// types
typedef _RealType result_type;
-
+
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __a_;
>From 5bf2e2fe14b6b48d9e5f1fba1bb032b2f608cbd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= <“nhat7203 at gmail.com”>
Date: Sat, 28 Oct 2023 14:02:08 -0400
Subject: [PATCH 2/3] Revert "add static assert to check for floating type"
This reverts commit 477dd014e50ddcd6c7e118b46891f2c5cd409eec.
---
libcxx/include/__random/uniform_real_distribution.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libcxx/include/__random/uniform_real_distribution.h b/libcxx/include/__random/uniform_real_distribution.h
index 8514f734a4d75b4..1388cef95f39414 100644
--- a/libcxx/include/__random/uniform_real_distribution.h
+++ b/libcxx/include/__random/uniform_real_distribution.h
@@ -27,11 +27,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _RealType = double>
class _LIBCPP_TEMPLATE_VIS uniform_real_distribution
{
- static_assert(std::is_floating_point<_RealType>::value, "result_type must be of type floating point");
public:
// types
typedef _RealType result_type;
-
+
class _LIBCPP_TEMPLATE_VIS param_type
{
result_type __a_;
>From f4263f7932558baed0eaaf1aef9f5151a578ccea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= <“nhat7203 at gmail.com”>
Date: Sat, 28 Oct 2023 14:11:01 -0400
Subject: [PATCH 3/3] add static assert for floating point type for uniform
distribution
---
libcxx/include/__random/uniform_real_distribution.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libcxx/include/__random/uniform_real_distribution.h b/libcxx/include/__random/uniform_real_distribution.h
index 1388cef95f39414..a20faa1e93e56cd 100644
--- a/libcxx/include/__random/uniform_real_distribution.h
+++ b/libcxx/include/__random/uniform_real_distribution.h
@@ -27,6 +27,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _RealType = double>
class _LIBCPP_TEMPLATE_VIS uniform_real_distribution
{
+ static_assert(std::is_floating_type<_RealType>::value, "result_type must be of type floating point");
+
public:
// types
typedef _RealType result_type;
More information about the libcxx-commits
mailing list