【发布时间】:2023-02-22 16:00:24
【问题描述】:
POD 是否可以隐式转换到 POD 或从 POD 转换为 POD?
struct Data
{
int a;
#ifdef __cplusplus
POD(int _a) : a(_a) {}
operator int() const { return a; }
#endif
}
请注意,我也需要 Data 才能成为 C++ 中的 POD,我只想将隐式转换作为语法糖。所以我需要编译器对 POD 进行的优化,因为它用在程序的热路径中。
【问题讨论】:
-
你找到答案here