inout and opApply
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jun 20 06:55:10 PDT 2016
On 06/20/2016 04:47 PM, Shachar Shemesh wrote:
> Please consider the following program:
>
> struct V(T) {
> int opApply(scope int delegate(ref T value) dg) {
> return 0;
> }
> int opApply(scope int delegate(ref const T value) dg) const {
> return 0;
> }
> }
>
> struct V1(T) {
> int opApply(scope int delegate(ref inout T value) dg) inout {
> return 0;
> }
> }
>
> void main() {
> const V!int mytype1;
> V!int mytype2;
> V1!int mytype3;
>
> foreach( v; mytype1 ) {
> }
> foreach( v; mytype2 ) {
> }
> foreach( v; mytype3 ) { // <- This line doesn't compile: cannot
> uniquely infer foreach argument types
> }
> }
>
> So the only way to get inout to work is... not to use it?
>
> Shachar
I think Steven has mentioned this issue during his DConf inout talk.
More information about the Digitalmars-d
mailing list