Re: Template member function cast bug in VC80SP1 (and more...)
"Mycroft Holmes" wrote:
// Why do you think it's illegal? It compiles both by
VC++2005
// and Comeau online compiler wihtout any warning.
No, VC2005 SP1 does NOT compile:
[...]
Ah. I missed that. I tried with classes only. You're right
here. Comeau doesn't compile it either.
// Alternatively, you can use `__if_exists' compiler
intrinsic:
If I understand correctly, this is not a compile-time
constant
Yes. It behaves as run-time `if' statement. Moreover, I
discovered that `__if_exists' works only with classes. What
a shame! This code erroneously indicates that `swap' member
exists:
template <typename T>
bool if_swap_exists(const T&)
{
bool b = false;
__if_exists(T::swap) { b = true };
return b;
}
int main()
{
int x = 0;
cout << if_swap_exists(x) << endl;
return 0;
}
// // (problem 3: very important)
// [Did you mean (c.*memptr)(...), where `memptr' is third
// parameter?]
NO! this is the key point: I don't want to USE the runtime
pointer, but
a compile-time function call (in fact I pass a pointer
just to select
the right overload)
I see now.
// The error is misleading. The real problem is again
// inaccessibility of `VECTOR::erase' due to private
// inheritance. Comeau online reports correct error about
it.
// Once appropriate `MAP_BASE::erase' is available both
Comeau
// and VC++ compile the code without any problem.
Are you sure? All compilers I tried do compile with both
public/private
inheritance, including Comeau (I copied and pasted the
sample I posted previously).
VC8 SP1 instead never compiles. Which settings did you
use?
Now I understand. I uncommented `iterator erase(iterator
pos)' definiton in `MAP_BASE'. That slves the problem.
However, you already found this workaround by yourself. I'm
afraid that you'll need to live with that as long as
VC++2005 is your compiler.
Alex