Function hijack on selective import
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Jan 16 20:30:43 UTC 2018
On Tue, Jan 16, 2018 at 07:14:00PM +0000, rumbu via Digitalmars-d-learn wrote:
> On Tuesday, 26 December 2017 at 20:21:11 UTC, Adam D. Ruppe wrote:
> > On Tuesday, 26 December 2017 at 19:41:47 UTC, rumbu wrote:
> > > "Custom" is a templated struct. I cannot imagine all the
> > > instantiations of Custom to write template specialisations for
> > > each of them.
> >
> > You can specialize on templated structs generically.
> >
> > int foo(T : Bar!(X, Y), X, Y)
> >
> > that kind of thing covers any case of Bar!(X,y)
>
> Even specialized, now I have another problem:
>
> std.math:
>
> int signbit(X)(X x) { ... }
>
> mylibrary:
>
> int signbit(D: Decimal!bits, int bits) { ... }
>
> =============
>
> end user:
>
> import std.math;
> import mylibrary;
>
> Decimal!32 d;
> float f;
>
> auto y = signbit(f); //ok, call to std.math.signbit
> auto x = signbit(d); //error, also calls std.math.signbit
Arguably, this is a defect in Phobos. Looking at the definition of
std.math.signbit, it's obvious that it's only meant to handle built-in
floating-point types, yet there are no sig constraints to that effect.
Fix: https://github.com/dlang/phobos/pull/6040
T
--
The computer is only a tool. Unfortunately, so is the user. -- Armaphine, K5
More information about the Digitalmars-d-learn
mailing list