opCast / operator overloading with additional template arguments

Paul paultjeadriaanse at gmail.com
Mon Jan 11 03:40:41 UTC 2021


On Monday, 11 January 2021 at 00:48:49 UTC, Steven Schveighoffer 
wrote:
> I would think though, that this should work:
>
> T opCast(T : Vec!(vecsize, S), S)()

Oh wouw, this seems to work perfectly! Awesome thanks ^^

Any Idea why
> T opCast(T, S)() const if (is(T : Vec!(grootte, S))) {
yields the error
> template instance opCast!(Vec!(2, double)) does not match 
> template declaration opCast(T, S)()
while your suggestion does not? It seems to me it should match 
equally well.

Also I had no clue types inferred in constraints were 
inaccessibly, I'll try to keep that in mind, though I wonder, is 
there is any specific reason for that? Then again since your 
example works inferred values shouldnt be necessary in 
constraints anyway.
(On that note, is there per chance something like the underscore 
'_' as in python? In some cases I don't care for all the template 
arguments inside an is expression (with the (a:b, c) version))


More information about the Digitalmars-d-learn mailing list