Add uniform_inside_sphere_distribution

Jonathan Wakely jwakely@redhat.com
Wed Oct 26 09:01:00 GMT 2016


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.



More information about the Libstdc++ mailing list