On Tuesday, 13 June 2017 at 20:45:34 UTC, jmh530 wrote:


Fair point. I just was playing around with it today and was like, oh that's pretty easy. It was only when I was trying to see if anyone else had done anything like this that I came across your project.

I was just looking at the code in the package. There was an earlier discussion on predicates. If you changed the Read/RefRead/etc structs to be something like below, then the user could add in a string of the assert. It's not really all that elegant, but I think you should be able to get it to work.

struct Read
{
        string visibility = "public";
        string constraint = void;
}

My ideal was to get something working where the lower and upper bounds were actual values, so you didn't have to pass the string, but I can see how that gets complicated. One problem I ran into is that you can't really make a struct templated in an optional way. For instance, the following won't compile (ignoring the complexity of making the asserts > or >=):

struct Read(T = void)
{
        string visibility = "public";
        static if (!is(T == void)) {
                T lower;
                T upper;
        }
}

void main()
{
        Read read;
}


Reply via email to