Was ist der Unterschied zwischen der Verwendung von Funktion und Makro, wenn Sie die maximale Var erhalten?
Beim Lesen des combase.cpp-Codes finde ich Folgendes:
/* We have to ensure that we DON'T use a max macro, since these will typically */
/* lead to one of the parameters being evaluated twice. Since we are worried */
/* about concurrency, we can't afford to access the m_cRef twice since we can't */
/* afford to run the risk that its value having changed between accesses. */
template<class T> inline static T ourmax( const T & a, const T & b )
{
return a > b ? a : b;
}
Ich verstehe nicht, warum "max macro dazu führt, dass einer der Parameter zweimal ausgewertet wird"?