Re: Explicitly specializing std::min() on VC++ 2005 Express Edition
"Tom Widmer [VC++ MVP]" <tom_usenet@hotmail.com> schrieb im Newsbeitrag
news:uCq1XvVkHHA.4188@TK2MSFTNGP02.phx.gbl...
The problem is that VC2005 is ignoring 5.16/4 (about ?: ):
"If the second and third operands are lvalues and have the same type, the
result is of that type and is an lvalue."
Instead, it is applying the lvalue-to-rvalue conversion (e.g. the
array-to-pointer conversion) to the parts of the ?: expression, and thus
trying to return a pointer where an array is expected.
That's good news, I first thought that there was a bug in my code.
template <class T> inline
const T& minimum( const T& a, const T& b )
{
// Note the 'const' before 'T'.
return minimum_impl<const T>::impl( a, b );
}
That's a bit of an odd way of doing it, since it means you always have to
specialize for const T, rather than T, as is usual.
See above. Just to be clear, this compiles and works on VC2005:
[snipping code]
It works! Thanks, things are much clearer to me now! :-)
--
Matthias Hofmann
Anvil-Soft, CEO
http://www.anvil-soft.com - The Creators of Toilet Tycoon
http://www.anvil-soft.de - Die Macher des Klomanagers