This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Add uniform_inside_sphere_distribution
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Ed Smith-Rowland <3dw4rd at verizon dot net>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 26 Oct 2016 10:01:11 +0100
- Subject: Re: Add uniform_inside_sphere_distribution
- Authentication-results: sourceware.org; auth=none
- References: <545A6BD6.5050706@verizon.net> <alpine.DEB.2.11.1411052223020.1572@laptop-mg.saclay.inria.fr> <545AB59D.3080906@verizon.net> <alpine.DEB.2.11.1411060814090.1570@laptop-mg.saclay.inria.fr> <545CF258.7050604@verizon.net> <20161024165302.GM2922@redhat.com> <d037f3cf-f4d5-3ecf-882b-9583080d5f9e@verizon.net> <26a70cdc-b9ba-d9df-7597-87354376dfb5@verizon.net>
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.
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.
+// { dg-require-cstdint "" }
+//
+// Copyright (C) 2014 Free Software Foundation, Inc.
And update the dates to 2014-2016.
OK for trunk with those changes to the tests. Whether to use
DEBUG_ASSERT/assert is your call.
Thanks.