Re: std.traits.isBoolean

2018-02-19 Thread Tony via Digitalmars-d-learn
On Monday, 19 February 2018 at 17:22:04 UTC, Nathan S. wrote: On Monday, 19 February 2018 at 15:12:15 UTC, Tony wrote: But, assuming there is a use case for it, what if you want to restrict to a type that is either boolean, or a struct/class that can substitute for boolean - how do you do that

Re: std.traits.isBoolean

2018-02-19 Thread Nathan S. via Digitalmars-d-learn
On Monday, 19 February 2018 at 15:12:15 UTC, Tony wrote: But, assuming there is a use case for it, what if you want to restrict to a type that is either boolean, or a struct/class that can substitute for boolean - how do you do that without using the "private" TypeOfBoolean thing? In that ca

Re: std.traits.isBoolean

2018-02-19 Thread Tony via Digitalmars-d-learn
On Monday, 19 February 2018 at 13:47:15 UTC, Basile B. wrote: Indeed but Phobos maintainers don't want the ...TypeOf family to be documented. (https://github.com/dlang/phobos/pull/5747) Ok, thanks. But, assuming there is a use case for it, what if you want to restrict to a type that is ei

Re: std.traits.isBoolean

2018-02-19 Thread Basile B. via Digitalmars-d-learn
On Monday, 19 February 2018 at 13:07:08 UTC, Tony wrote: It doesn't appear that BooleanTypeof is documented on dlang.org (outside of it's placement on the isBooleanType page). At least it isn't coming up in a "BooleanTypeOf site:dlang.org" search and not on the traits page: https://dlang.org/

Re: std.traits.isBoolean

2018-02-19 Thread Tony via Digitalmars-d-learn
On Sunday, 18 February 2018 at 15:12:50 UTC, Mike Parker wrote: Generally, no. But with alias this, it can be: = import std.traits : BooleanTypeOf; import std.stdio : writeln; struct NoBool { int x; } struct AliasThisBool { bool b; alias b this; } void main() { static if(

Re: std.traits.isBoolean

2018-02-18 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 18 February 2018 at 14:52:37 UTC, Tony wrote: At https://dlang.org/library/std/traits/is_boolean.html it has: enum isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T; per: https://dlang.org/library/std/traits/is_aggregate_type.html isAggregateType is true for [struct, union,