This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [patch] libstdc++/69240 generic operator!= for random number distributions


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


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