Compile time opAssign/@property constraints
Jacob Shtokolov
jacob.100205 at gmail.com
Fri Jan 4 11:45:24 UTC 2019
On Friday, 4 January 2019 at 10:34:07 UTC, Basile.B wrote:
> Show us some code.
Here is the simple example:
https://run.dlang.io/gist/1a06dd703bea5548ee72b4713a7ce5f6
The thing I'm trying to do is to make an experimental port (for
education purposes) of https://github.com/fthomas/refined library
for Scala, which allows to set constraints on basic types like
numeric, bool, string, etc.
For example, you can force an integer variable to take a range
between 0 and 15. And if constraint is not satisfied, you get a
compile time error.
There is no predicate in my example, but even if I add one (using
alias template parameter), it shows the same error.
So is that possible in D?
More information about the Digitalmars-d-learn
mailing list