1 /** Check presence of proposed extensions/modifications to the D language itself.
2  *
3  * See_Also: https://forum.dlang.org/post/acjltvvqhfcchpwgodqn@forum.dlang.org
4  */
5 module nxt.dlang_traits;
6 
7 @safe pure nothrow @nogc:
8 
9 /// Is `true` if D supports `foreach (const ref e; range)`.
10 private enum hasRefForeach = __traits(compiles, {
11         mixin(`void f() { int[2] _ = [1, 2]; foreach (const ref e; _) {} }`);
12     });
13 
14 /// Is `true` if D supports `foreach (const auto ref e; range)`.
15 private enum hasAutoRefForeach = __traits(compiles, () {
16         mixin(`void f() { int[2] _ = [1, 2]; foreach (const auto ref e; _) {} }`);
17     });
18 
19 ///
20 unittest
21 {
22     static assert(hasRefForeach);
23     static assert(!hasAutoRefForeach);
24 }