This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add uniform_inside_sphere_distribution


On 10/26/2016 05:01 AM, Jonathan Wakely wrote:
On 25/10/16 08:20 -0400, Ed Smith-Rowland wrote:
+    explicit
+    param_type(_RealType __radius = _RealType(1))
+    : _M_radius(__radius)
+    {
+      _GLIBCXX_DEBUG_ASSERT(_M_radius > _RealType(0));

Nowadays we're able to do cheaper assertions when _GLIBCXX_ASSERTIONS
is defined, without the full debug mode (i.e. _GLIBCXX_DEBUG).

The macro above is only active for the full debug mode, but it looks
like a cheap check, should it use __glibcxx_assert instead?

It looks like we're not consistent about which one to use in
<ext/random>, which is probably my fault. Expensive checks like using
std::distance on forward iterators should use _GLIBCXX_DEBUG_ASSERT
but some of them look like they could use __glibcxx_assert.

This parameter check could definitely use __glibcxx_assert.

In fact, these two features look like 2/3 of the contracts proposal for C++ almost. Or at least they could help.

Index: testsuite/ext/random/uniform_inside_sphere_distribution/cons/default.cc
===================================================================
--- testsuite/ext/random/uniform_inside_sphere_distribution/cons/default.cc (nonexistent) +++ testsuite/ext/random/uniform_inside_sphere_distribution/cons/default.cc (working copy)
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++11" }

In all the new tests please replace this dg-options directive with:

 { dg-do run { target cxx11 } }

so it can be tested for C++14 and C++17 too.
Done.
+// { dg-require-cstdint "" }
+//
+// Copyright (C) 2014 Free Software Foundation, Inc.

And update the dates to 2014-2016.
Done.

Committed as 241562 with the attached .


Attachment: patch_uisd2
Description: Text document

Attachment: CL_uisd
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]