Bug 8461 – std.container.SList can't work with std.typecons.Proxy

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-29T09:13:00Z
Last change time
2013-03-11T19:12:33Z
Assigned to
nobody
Creator
cpunion

Comments

Comment #0 by cpunion — 2012-07-29T09:13:43Z
code: --- import std.typecons; import std.container; class Foo { this(int n) { value = n; } mixin Proxy!(value); private int value; } void main() { SList!Foo list; list.insertFront(new Foo(1)); } --- compiler output: --- $ dmd testslist.d /home/lijie/.dvm/compilers/dmd-2.059/bin/../src/phobos/std/container.d(938): Error: template testslist.Foo.Proxy!(value).opCast does not match any function template declaration /home/lijie/.dvm/compilers/dmd-2.059/bin/../src/phobos/std/typecons.d(2796): Error: template testslist.Foo.Proxy!(value).opCast(T,this X) cannot deduce template function from argument types !(Object)() /home/lijie/.dvm/compilers/dmd-2.059/bin/../src/phobos/std/container.d(938): Error: template testslist.Foo.Proxy!(value).opCast does not match any function template declaration /home/lijie/.dvm/compilers/dmd-2.059/bin/../src/phobos/std/typecons.d(2796): Error: template testslist.Foo.Proxy!(value).opCast(T,this X) cannot deduce template function from argument types !(Object)() testslist.d(15): Error: template instance std.container.SList!(Foo) error instantiating ---
Comment #1 by cpunion — 2012-07-29T09:53:26Z
Shorter code: --- import std.container; class Foo { this(int n) { value = n; } T opCast(T)() { return cast(T)value; } private int value; } void main() { SList!Foo list; } --- compile: --- $ dmd testslist.d /home/lijie/.dvm/compilers/dmd-2.059/bin/../src/phobos/std/container.d(938): Error: function testslist.Foo.opCast!(Object).opCast () is not callable using argument types () /home/lijie/.dvm/compilers/dmd-2.059/bin/../src/phobos/std/container.d(938): Error: function testslist.Foo.opCast!(Object).opCast () is not callable using argument types () testslist.d(16): Error: template instance std.container.SList!(Foo) error instantiating ---
Comment #2 by k.hara.pg — 2013-03-11T19:12:33Z
Works in 2.063alpha.