Re: Optional type parameter on a template

2020-05-12 Thread Luis via Digitalmars-d-learn
On Tuesday, 12 May 2020 at 20:40:35 UTC, Adam D. Ruppe wrote: A default argument of void is a common way to do it template foo(T = void) { static if(is(T == void)) { not given } else { use T } } Perfect! Works as I desired.

Re: Optional type parameter on a template

2020-05-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 May 2020 at 20:36:22 UTC, Luis wrote: I'm trying to make a SparseSet that on function of a optional type parameter, could alongside the index set, store other data. So I need a way to declare a optional type template parameter. A default argument of void is a common way to do

Optional type parameter on a template

2020-05-12 Thread Luis via Digitalmars-d-learn
I'm trying to make a SparseSet that on function of a optional type parameter, could alongside the index set, store other data. So I need a way to declare a optional type template parameter. I prototyped this stuff on run.dlang, but I like know if there is a better way : https://run.dlang.io

Re: Optional type parameter on a template

2020-05-12 Thread Luis via Digitalmars-d-learn
Sorry ... wrong link. This is the correct : https://run.dlang.io/is/D2iCP0