[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
what's the difference between (size_t)n and size_t(n)? Bug?
From: |
Ulrich Lauther |
Subject: |
what's the difference between (size_t)n and size_t(n)? Bug? |
Date: |
Wed, 29 Oct 2008 12:19:42 +0000 (UTC) |
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
- what's the difference between (size_t)n and size_t(n)? Bug?,
Ulrich Lauther <=