This code:

#include <stdio.h>

class Foo {
  size_t m_n;
public:
  inline explicit Foo(size_t n) : m_n(n) {
  }
  inline int operator()(int i) {
    return i;
  }
}; // Foo

int main() {

  int n = 10;
  Foo my_foo(size_t(n));
  // Foo my_foo((size_t)n);

  int i = 1;
  i += my_foo(i);
  printf("%d\n",i);
  return 0;
}

Gives:

test.C: In function 'int main()':
test.C:20: error: no match for 'operator+=' in 'i += my_foo(((size_t)i))'
test.C:15: warning: unused variable 'n'

When I use the commented out line, it works as expected.

Compiler version is 4.1.2

Regards,

        -ulrich
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to