Is this a bug?

Meta via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 26 06:24:59 PDT 2014


On Thursday, 26 June 2014 at 10:09:53 UTC, Rene Zwanenburg wrote:
> 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))

Yes, this is a bug. This code should work. If it doesn't compile 
with Git HEAD, you should file a bug report.


More information about the Digitalmars-d mailing list