Different behavior of consteval in GCC and MSVC (not work)(GCC与微软创业投资公司(非工作)的不同求职行为)
本文介绍了GCC与微软创业投资公司(非工作)的不同求职行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑以下代码:
#include <cstdint>
#include <vector>
class ClassT
{
public:
consteval static size_t GetSize()
{
return sizeof(int);
}
void Resize()
{
_Data.resize(GetSize(), 0);
}
std::vector<uint8_t> _Data;
};
int main()
{
ClassT Object;
Object.Resize();
return 0;
}
GCC编译成功,但msvc提示错误:
error C7595: 'ClassT::GetSize': call to immediate function is not a constant expression
我错过了什么吗?或者这真的是MSVC错误?
编译器版本:x86-64 gcc 10.2
和x64 msvc v19.28
。(Link to godbolt)
msvc
这看起来像推荐答案错误。它甚至可能与现有的这个相同-#1224555。
最小示例:
consteval int test() { return 0; }
int main() {
return test(); // error C7595: 'test': call to immediate function is not a constant expression
}
这篇关于GCC与微软创业投资公司(非工作)的不同求职行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:GCC与微软创业投资公司(非工作)的不同求职行为


猜你喜欢
- 如何提取 __VA_ARGS__? 2022-01-01
- 从父 CMakeLists.txt 覆盖 CMake 中的默认选项(...)值 2021-01-01
- 使用 __stdcall & 调用 DLLVS2013 中的 GetProcAddress() 2021-01-01
- 哪个更快:if (bool) 或 if(int)? 2022-01-01
- 将 hdc 内容复制到位图 2022-09-04
- OpenGL 对象的 RAII 包装器 2021-01-01
- GDB 不显示函数名 2022-01-01
- 将函数的返回值分配给引用 C++? 2022-01-01
- DoEvents 等效于 C++? 2021-01-01
- XML Schema 到 C++ 类 2022-01-01