mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
88 lines
1.3 KiB
D
88 lines
1.3 KiB
D
// https://issues.dlang.org/show_bug.cgi?id=22420
|
|
|
|
struct File
|
|
{
|
|
~this()
|
|
{
|
|
}
|
|
File impl()
|
|
{
|
|
return File.init;
|
|
}
|
|
alias impl this;
|
|
}
|
|
struct Variable
|
|
{
|
|
this(File)(File) { }
|
|
this(File)(File[]) { }
|
|
}
|
|
Variable wrapFunctionReturn(alias handler)(Variable params)
|
|
{
|
|
return Variable(handler(params));
|
|
}
|
|
void registerFile()
|
|
{
|
|
wrapFunctionReturn!((Variable) {
|
|
return File.init;
|
|
})(Variable.init);
|
|
}
|
|
|
|
// Reduction from an 'automem' test
|
|
|
|
struct Issue156 {}
|
|
|
|
void test2()
|
|
{
|
|
RefCounted!Issue156 s;
|
|
auto r1 = repeat(s);
|
|
zip(r1);
|
|
}
|
|
|
|
struct RefCounted(RefCountedType)
|
|
{
|
|
~this() {}
|
|
alias _impl this;
|
|
|
|
struct Impl {}
|
|
alias ImplType = Impl;
|
|
|
|
private ImplType* _impl;
|
|
|
|
}
|
|
template Tuple(Specs)
|
|
{
|
|
struct Tuple
|
|
{
|
|
this(U)(U) {}
|
|
this()(int) {}
|
|
}
|
|
}
|
|
|
|
template ElementType(R)
|
|
{
|
|
static if (is(typeof(R.init) T))
|
|
alias ElementType = T;
|
|
}
|
|
|
|
struct Repeat(T)
|
|
{
|
|
inout(T) front() inout {assert(0);}
|
|
}
|
|
|
|
Repeat!T repeat(T)(T ) {assert(0);}
|
|
|
|
auto zip(Ranges)(Ranges )
|
|
{
|
|
return ZipShortest!Ranges();
|
|
}
|
|
|
|
struct ZipShortest(Ranges...)
|
|
{
|
|
Ranges ranges;
|
|
alias ElementType = Tuple!(.ElementType!(Ranges[0]));
|
|
|
|
ElementType front()
|
|
{
|
|
return typeof(return)(ranges[0].front);
|
|
}
|
|
}
|