【问题标题】:What does ?: mean in C++? [duplicate]?: 在 C++ 中是什么意思? [复制]
【发布时间】:2021-05-17 19:17:23
【问题描述】:

我找到了这段代码:

std::string(avdInfo_getSystemImagePath(m_avd)
                                ?: avdInfo_getSystemInitImagePath(m_avd))

我只找到了关于条件运算符的信息:http://www.cplusplus.com/articles/1AUq5Di1/

也就是说,?和 : 是分开的。但是,当他们在一起时,这意味着什么? avdInfo_getSystemImagePathavdInfo_getSystemInitImagePath 都返回 char*

【问题讨论】:

    标签: c++


    【解决方案1】:

    这是GCC extension

    x ?: y
    

    相同
    x ? x : y
    

    除了x 只会被评估一次。

    【讨论】:

      猜你喜欢
      • 2019-09-12
      • 2015-06-25
      • 2019-12-08
      • 2013-02-12
      • 2011-06-10
      • 2014-02-02
      • 2014-06-25
      • 2014-11-08
      • 2011-05-06
      相关资源
      最近更新 更多