This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] libstdc++/69240 generic operator!= for random number distributions
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Jan 2016 19:21:35 +0000
- Subject: Re: [patch] libstdc++/69240 generic operator!= for random number distributions
- Authentication-results: sourceware.org; auth=none
- References: <20160114190628 dot GY15084 at redhat dot com> <alpine dot DEB dot 2 dot 20 dot 1601142009420 dot 8792 at laptop-mg dot saclay dot inria dot fr>
On 14/01/16 20:13 +0100, Marc Glisse wrote:
I didn't think about it much, but I am worried that __random_not_eq
will accidentally become an associated namespace for more classes than
we would expect.
Yes, it would be an associated namespace for types that derive from
the distributions, or class template specializations that use the
distributions as template arguments.
We could constrain the generic operator== and operator!= to only match
types that we want it to match, e.g. by having a type trait that is
true for all our distributions and their parameter types. That would
mean adding a specialization of it for each distribution and parameter
type:
template<typename _IntType>
struct
__is_comparable_random_dist<uniform_int_distribution<_IntType>>
: true_type { };
Having to do that for every type removes some of the advantages of the
patch, but would still be less code overall.
If the operators are constrained in that way then I don't think it's a
problem that the namespaces would be associated with more types,
because there's nothing else in those namespaces that could be found
by ADL.