gpt4 book ai didi

c++ - 获取最大变量时,使用函数和宏有什么区别

转载 作者:行者123 更新时间:2023-11-30 03:01:51 27 4
gpt4 key购买 nike

<分区>

阅读 combase.cpp 代码,我发现以下内容:

/* 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;
}

我不明白为什么“最大宏会导致其中一个参数被计算两次”?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com