Re: Function hijack on selective import

2018-01-16 Thread rumbu via Digitalmars-d-learn
On Tuesday, 16 January 2018 at 20:30:43 UTC, H. S. Teoh wrote: On Tue, Jan 16, 2018 at 07:14:00PM +, rumbu via 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

Re: Function hijack on selective import

2018-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 16, 2018 at 07:14:00PM +, 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

Re: Function hijack on selective import

2018-01-16 Thread rumbu via Digitalmars-d-learn
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

Re: Function hijack on selective import

2017-12-26 Thread rumbu via Digitalmars-d-learn
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

Re: Function hijack on selective import

2017-12-26 Thread Adam D. Ruppe via Digitalmars-d-learn
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

Re: Function hijack on selective import

2017-12-26 Thread rumbu via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 16:15:55 UTC, Adam D. Ruppe wrote: The mistake you're making is using a constraint when you should try a specialization: int signbit(T:Custom)(T x) { return 0; } That means to use this specialized function when T is Custom. Now, you just need to merge

Re: Function hijack on selective import

2017-12-26 Thread Adam D. Ruppe via Digitalmars-d-learn
The mistake you're making is using a constraint when you should try a specialization: int signbit(T:Custom)(T x) { return 0; } That means to use this specialized function when T is Custom. Now, you just need to merge the overload sets: import std.math; alias signbit =