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
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
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
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/
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(
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,
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, class, interface].
So BooleanTypeOf!T is true for struct