3

我找到了这段代码:

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

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

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

4

1 回答 1

7

这是一个GCC 扩展

x ?: y

是相同的

x ? x : y

除了x只会评估一次。

于 2021-02-14T18:58:42.407 回答