Type constraint

Salih Dincer salihdb at hotmail.com
Mon Oct 9 16:12:58 UTC 2023


On Tuesday, 3 October 2023 at 14:35:31 UTC, Joel wrote:
> Oh, I found,
> ```d
> static if (isIntegral!T)
> ```
> seems to work.

If you are using a struct, another way to affect the whole is as 
follows:

```d
struct S(T)
{

   invariant() {
       static assert(isIntegral!T);
   }

   auto addUp() { /**/ }
}
```
For detailed information and examples, please continue here:

https://tour.dlang.org/tour/en/gems/contract-programming

SDB at 79


More information about the Digitalmars-d-learn mailing list