diff options
| author | Eugen Wissner <belka@caraus.de> | 2017-09-01 19:38:44 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2017-09-01 19:38:44 +0200 |
| commit | 515bf619e8eea223593f2c465d412405e2909374 (patch) | |
| tree | cf1e15391fb603c4498f5de2175432e8f0c0302b | |
| parent | 617eaab9a2ef49b37e10a30cfdc9ba86a1ec53e5 (diff) | |
| download | tanya-515bf619e8eea223593f2c465d412405e2909374.tar.gz | |
Add support for dmd 2.076.0
| -rw-r--r-- | .travis.yml | 3 | ||||
| -rw-r--r-- | appveyor.yml | 6 | ||||
| -rw-r--r-- | source/tanya/meta/trait.d | 60 |
3 files changed, 67 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml index 176c2a0..84a483c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ os: language: d d: + - dmd-2.076.0 - dmd-2.075.1 - dmd-2.074.1 - dmd-2.073.2 @@ -22,7 +23,7 @@ addons: - gcc-multilib before_script: - - if [ "$PS1" = '(dmd-2.075.1)' ]; then + - if [ "$PS1" = '(dmd-2.076.0)' ]; then export UNITTEST="unittest-cov"; fi diff --git a/appveyor.yml b/appveyor.yml index 1eee97f..5c52adb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,12 @@ os: Visual Studio 2015 environment: matrix: - DC: dmd + DVersion: 2.076.0 + arch: x64 + - DC: dmd + DVersion: 2.076.0 + arch: x86 + - DC: dmd DVersion: 2.075.1 arch: x64 - DC: dmd diff --git a/source/tanya/meta/trait.d b/source/tanya/meta/trait.d index 697673f..6587fa2 100644 --- a/source/tanya/meta/trait.d +++ b/source/tanya/meta/trait.d @@ -210,6 +210,23 @@ pure nothrow @safe @nogc unittest } /** + * Returns the alignment of the type $(D_PARAM T). + * + * Params: + * T = A type. + * + * Returns: Alignment of the type $(D_PARAM T). + */ +enum size_t alignOf(T) = T.alignof; + +/// +pure nothrow @safe @nogc unittest +{ + static assert(alignOf!bool == bool.alignof); + static assert(is(typeof(alignOf!bool) == typeof(bool.alignof))); +} + +/** * Tests whether $(D_INLINECODE Args[0]) and $(D_INLINECODE Args[1]) are the * same symbol. * @@ -396,7 +413,8 @@ version (TanyaPhobos) hasElaborateDestructor, hasElaborateCopyConstructor, hasElaborateAssign, - EnumMembers; + EnumMembers, + classInstanceAlignment; } else: @@ -2627,3 +2645,43 @@ pure nothrow @nogc @safe unittest } static assert([E.one, E.two, E.three] == [ EnumMembers!E ]); } + +/** + * Different than $(D_INLINECODE T.alignof), which is the same for all class + * types, $(D_PSYMBOL classInstanceOf) determines the alignment of the class + * instance and not of its reference. + * + * Params: + * T = A class. + * + * Returns: Alignment of an instance of the class $(D_PARAM T). + */ +template classInstanceAlignment(T) +if (is(T == class)) +{ + private enum ptrdiff_t pred(U1, U2) = U1.alignof - U2.alignof; + private alias Fields = typeof(T.tupleof); + enum size_t classInstanceAlignment = Max!(pred, T, Fields).alignof; +} + +/// +pure nothrow @safe @nogc unittest +{ + class C1 + { + } + static assert(classInstanceAlignment!C1 == C1.alignof); + + struct S + { + align(8) + uint s; + + int i; + } + class C2 + { + S s; + } + static assert(classInstanceAlignment!C2 == S.alignof); +} |
