View source code
Display the source code in std/traits.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Enum member std.traits.allSameType

enum allSameType(T...) = true;

Returns

true iff all types T are the same.

Example

static assert(allSameType!(int, int));
static assert(allSameType!(int, int, int));
static assert(allSameType!(float, float, float));
static assert(!allSameType!(int, double));
static assert(!allSameType!(int, float, double));
static assert(!allSameType!(int, float, double, real));
static assert(!allSameType!(short, int, float, double, real));
}

/**
Returns: `true` iff the type `T` can be tested in an <code class="lang-d"><span class="kwd">if</span></code>-expression, that is if <code class="lang-d"><span class="kwd">if </span><span class="pun">(</span><span class="pln">pred</span><span class="pun">(</span><span class="pln">T<wbr/></span><span class="pun">.</span><span class="pln">init</span><span class="pun">)) {}</span></code> is compilable.
*/
enum ifTestable(T, alias pred = a => a) = __traits(compiles, { if (pred(T.init)) {} 

Authors

Walter Bright, Tomasz Stachowiak (isExpressions), Andrei Alexandrescu, Shin Fujishiro, Robert Clipsham, David Nadlinger, Kenji Hara, Shoichi Kato

License

Boost License 1.0.