[libcxx-commits] [libcxx] [libc++] Fixed uniform_real_distribution.h where it was allowing initialization with non floating point types (PR #70471)

Pranav Tatavarthy via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 27 09:13:42 PDT 2023


https://github.com/Pranav10903 created https://github.com/llvm/llvm-project/pull/70471

None

>From 52cb5d88e3a4bd347f6993405b18480acc0835f1 Mon Sep 17 00:00:00 2001
From: Pranav Tatavarthy <97344709+Pranav10903 at users.noreply.github.com>
Date: Fri, 27 Oct 2023 21:41:41 +0530
Subject: [PATCH] Update uniform_real_distribution.h

---
 libcxx/include/__random/uniform_real_distribution.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcxx/include/__random/uniform_real_distribution.h b/libcxx/include/__random/uniform_real_distribution.h
index 1388cef95f39414..8268dc4f14327c0 100644
--- a/libcxx/include/__random/uniform_real_distribution.h
+++ b/libcxx/include/__random/uniform_real_distribution.h
@@ -27,6 +27,7 @@ _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 a floating point type");
 public:
     // types
     typedef _RealType result_type;



More information about the libcxx-commits mailing list