Bind C++ template specialized with void parameter

DUser duser at dlang.org
Thu Feb 29 10:30:59 UTC 2024


On Wednesday, 28 February 2024 at 22:48:33 UTC, Gregor Mückl 
wrote:
> ...
> But how can I bind Wrapper\<void> in D? Specifically, how do I 
> even express that template specialization in D syntax?

Did you mean any of these?

1. Parameter specialization:
```d
extern(C++, class):
class Wrapper(T) {...}
class Wrapper(T : void) {...}
```
2. Template constraints:
```d
extern(C++, class):
class Wrapper(T) if(!is(T == void)) {...}
class Wrapper(T) if(is(T == void)) {...}
```
3. `static if`:
```d
extern(C++, class)
class Wrapper(T) {
   static if (!is(T == void))
     private T t;
   private bool valid;
   public final isValid();
}
```


More information about the Digitalmars-d-learn mailing list