This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] libstdc++/69240 generic operator!= for random number distributions
- From: Daniel KrÃgler <daniel dot kruegler at gmail dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 14 Jan 2016 21:22:01 +0100
- 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> <20160114192135 dot GZ15084 at redhat dot com>
2016-01-14 20:21 GMT+01:00 Jonathan Wakely <jwakely@redhat.com>:
> 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.
If there were an __is_direct_base_of intrinsic (or is there?), it
seems to me that there would be no need for all these specializations
(each one nearly taking as much space as the explicit inline
definition of operator!) and there could be a single constrained
operator!= that would only trigger for types that are direct base
classes of __tag.
- Daniel