Strange Error using parameterized opAssign for a struct

d coder dlang.coder at gmail.com
Tue Jul 5 03:20:41 PDT 2011


Hello Robert

As I try adding more code, I get into more and more issues with integral
parameters. See the following code:

Regards
- Puneet

// File implicit.d
alias int R;
// alias size_t R;
struct Foo (R N) {
  version(v1) {void opAssign (R NN)(Foo!NN f) {/*do nothing*/}}
  version(v2) {void opAssign (T:Foo!NN, R NN)(T f) {/*do nothing*/}}
  @property Foo!(I) range(R I)() {return Foo!(I)();}
}
void main() {
  Foo!4 foo1;
  Foo!7 foo2;
  foo2 = foo1; // compiles with both v2 and v1/(only when R is aliased to
int)
  foo2 = foo1.range!4; // compiles with v1/int and v2/int -- does not
compile with R alias to size_t
  foo2 = foo1.range!2; // compiles only with v1/int -- does not compile with
v2 at all
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110705/c852a71f/attachment.html>


More information about the Digitalmars-d mailing list