I /think/ this is a bug, but I'm not 100% sure. The following compiles without any problems, as it should:

import std.typecons;

alias Handle(T) = RefCounted!(T, RefCountedAutoInitialize.no);

auto initialized(T)() if(is(T == RefCounted!S, S...))
{
        T refCounted;
        refCounted.refCountedStore.ensureInitialized();
        return refCounted;
}

alias S = Handle!S_Impl;
struct S_Impl
{
}

void main()
{
        auto s = initialized!S;
}


Change 'initialized' to:
auto initialized(T)() if(is(T == Handle!S, S))
and the compiler will complain:

Error: template instance test.initialized!(RefCounted!(S_Impl, cast(RefCountedAutoInitialize)0)) does not match template declaration initialized(T)() if (is(T == Handle!S, S))

Reply via email to