Added Not, And, and Or to std.typetuple.#689
Conversation
The provide negation, logical and, and logical or for eponymous templates which resolve to boolean values.
|
Should be extended to work on predicates which operate on aliases/values as well. |
|
I thought the convention was to use camelCase for templates that resolve to values and PascalCase for templates that resolve to types? |
|
@alexrp: The result of the proposed templates is another template (they are »higher-order predicates«), and thus it makes sense for them to be Pascal-cased. I think the implementations are of |
I believe that it'll work on them as long as the template that you pass to them works on them. I didn't make it work on functions like I did with
You mean make it so that in
If you have a better one, please post it. But I believe that I need If it's going to take you a while to deal with creating a pull request, I can create one with your implementations if you point me to them (that link has |
|
Hm, replying via mail seems to disable Markdown processing…
No, because only types are accepted by the T parameter of the "returned"
Yes, I was indeed proposing that later predicates are not evaluated. But I found this to be quite helpful when working on the Thrift compile-time /**
* Wraps the passed template predicate so it returns true if it compiles and
* evaluates to true, false it it doesn't compile or evaluates to false.
*/
template CompilesAndTrue(alias T) {
template CompilesAndTrue(U...) {
static if (is(typeof(T!U) : bool)) {
enum bool CompilesAndTrue = T!U;
} else {
enum bool CompilesAndTrue = false;
}
}
}
|
Hmm. Well, I tried using an
Okay. Thanks. |
I should have thought of making them work on more than two arguments (in which case |
|
Okay, the pull request is up. Took me forever because I hit a nasty compiler bug in the unit tests, and tried to reduce it without success… |
|
Okay. I'll close this one, since yours is clearly better, and if there are any issues with it, we can just adjust that code appropriately. |
The provide negation, logical and, and logical or for eponymous
templates which resolve to boolean values.