/* REQUIRED_ARGS: -HC -c -o- PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler #pragma once #include #include #include #include #ifdef CUSTOM_D_ARRAY_TYPE #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE #else /// Represents a D [] array template struct _d_dynamicArray final { size_t length; T *ptr; _d_dynamicArray() : length(0), ptr(NULL) { } _d_dynamicArray(size_t length_in, T *ptr_in) : length(length_in), ptr(ptr_in) { } T& operator[](const size_t idx) { assert(idx < length); return ptr[idx]; } const T& operator[](const size_t idx) const { assert(idx < length); return ptr[idx]; } }; #endif typedef uint$?:32=32|64=64$_t size_t; struct Outer final { int32_t a; struct Member final { typedef int32_t Nested; Member() { } }; Outer() : a() { } Outer(int32_t a) : a(a) {} }; enum : int32_t { SomeOtherLength = 1 }; struct ActualBuffer final { ActualBuffer() { } }; template struct A final { T x; enum : int32_t { Enum = 42 }; static int32_t GsharedNum; const int32_t MemNum; void foo(); A() { } }; template struct NotInstantiated final { NotInstantiated() { } }; struct B final { A x; B() : x() { } B(A x) : x(x) {} }; template struct Foo final { T val; Foo() { } }; template struct Bar final { Foo v; Bar() { } }; template struct Array final { typedef Array This; typedef typeof(1 + 2) Int; typedef typeof(T::a) IC; Array(size_t dim); ~Array(); void get() const; template bool opCast() const; typename T::Member i; typename Outer::Member::Nested j; void visit(typename T::Member::Nested i); Array() { } }; template extern T foo(U u); extern A > aaint; template class Parent { public: T parentMember; void parentFinal(); virtual void parentVirtual(); }; template class Child final : public Parent { public: T childMember; void parentVirtual() override; T childFinal(); }; extern void withDefTempl(A a = A(2, 13)); template extern void withDefTempl2(A a = static_cast>(A(2))); class ChildInt : public Parent { }; struct HasMixins final { void foo(int32_t t); HasMixins() { } }; template struct HasMixinsTemplate final { void foo(T t); HasMixinsTemplate() { } }; extern HasMixinsTemplate hmti; template struct NotAA final { enum : int32_t { length = 12 }; T buffer[length]; T otherBuffer[SomeOtherLength]; T calcBuffer[foo(1)]; NotAA() { } }; template struct BufferTmpl final { Buffer buffer; Buffer buffer2; BufferTmpl() { } }; struct ImportedBuffer final { typedef ActualBuffer Buffer; ActualBuffer buffer2; ImportedBuffer() : buffer2() { } ImportedBuffer(ActualBuffer buffer2) : buffer2(buffer2) {} }; --- */ extern (C++) struct A(T) { T x; enum Enum = 42; __gshared GsharedNum = 43; immutable MemNum = 13; void foo() {} } // Invalid declarations accepted because it's not instantiated extern (C++) struct NotInstantiated(T) { enum T noInit; enum missingSem = T.init; } extern (C++) struct B { A!int x; } // https://issues.dlang.org/show_bug.cgi?id=20604 extern(C++) { struct Foo (T) { T val; } struct Bar (T) { Foo!T v; } } extern (C++) struct Array(T) { alias This = typeof(this); alias Int = typeof(1 + 2); alias IC = typeof(T.a); this(size_t dim) pure nothrow {} @disable this(this); ~this() {} void get() const {} bool opCast(T)() const pure nothrow @nogc @safe if (is(T == bool)) { return str.ptr !is null; } T.Member i; Outer.Member.Nested j; void visit(T.Member.Nested i) {} } struct Outer { int a; static struct Member { alias Nested = int; } } // alias AO = Array!Outer; extern(C++) T foo(T, U)(U u) { return T.init; } extern(C++) __gshared A!(A!int) aaint; extern(C++) class Parent(T) { T parentMember; final void parentFinal() {} void parentVirtual() {} } extern(C++) final class Child(T) : Parent!T { T childMember; override void parentVirtual() {} T childFinal() { return T.init; } } extern(C++) void withDefTempl(A!int a = A!int(2)) {} extern(C++) void withDefTempl2(T)(A!T a = A!T(2)) {} extern(C++) alias withDefTempl2Inst = withDefTempl2!int; extern(C++) class ChildInt : Parent!int {} /****************************************************** * Mixins */ extern (C++): mixin template MixinA(T) { void foo(T t) {} } mixin template MixinB() {} struct HasMixins { mixin MixinA!int; mixin MixinB; } struct HasMixinsTemplate(T) { mixin MixinA!T; mixin MixinB; } __gshared HasMixinsTemplate!bool hmti; /// Declarations that look like associative arrays extern(D) enum SomeOtherLength = 1; struct NotAA(T) { private: enum length = 12; public: T[length] buffer; T[SomeOtherLength] otherBuffer; T[foo(1)] calcBuffer; } // Same name but hidden by the template paramter extern (D) struct Buffer {} extern (D) struct ActualBuffer {} struct BufferTmpl(Buffer) { Buffer buffer; mixin BufferMixin!(); } struct ImportedBuffer { alias Buffer = ActualBuffer; mixin BufferMixin!(); } mixin template BufferMixin() { Buffer buffer2; }