C++ 错误:表达式必须具有常量值。对于一个明确的常数

C++ 错误:表达式必须具有常量值。对于一个明确的常数,c++,visual-studio-2015,constexpr,C++,Visual Studio 2015,Constexpr,我有一个非常简单的项目,它在VS2015中产生了奇怪的行为: #include "Vec2f.h" #include "StaticRendercomponent.h" int main(int argc, char** argv) { constexpr Vec2f position(0.0f, 0.0f); constexpr PhysicsComponent component(position, 15.0f); return

我有一个非常简单的项目,它在VS2015中产生了奇怪的行为:

#include "Vec2f.h"
#include "StaticRendercomponent.h"

int main(int argc, char** argv)
{
   constexpr Vec2f position(0.0f, 0.0f);
   constexpr PhysicsComponent component(position, 15.0f);

   return 0;
}
VS2015以红色突出显示构造函数中的
位置
参数。 将鼠标悬停在突出显示上时,将显示以下消息:

constexpr Vec2f position = {(0.0f), (0.0f)}

expression must have constant value
与错误突出显示和消息相反,程序编译和运行时不会出现故障,生成日志中没有任何消息,警告级别为4,并且“将警告视为错误”处于活动状态

让VS显示这样的错误并继续编译我的程序,而不在构建日志中显示消息是。。。至少可以说令人不安

为什么显示此消息?
为什么不停止应用程序的编译和运行?

可疑的人 Vec2f的构造函数:

constexpr Vec2f::Vec2f(const float x, const float y) noexcept:
   x(x),
   y(y)
{
}
constexpr PhysicsComponent::PhysicsComponent(Vec2f position, float mass, Vec2f momentum) noexcept:
   current(position, mass, momentum),
   previous(current),
   interpolated(current)
{
}
PhysicComponent构造函数:

constexpr Vec2f::Vec2f(const float x, const float y) noexcept:
   x(x),
   y(y)
{
}
constexpr PhysicsComponent::PhysicsComponent(Vec2f position, float mass, Vec2f momentum) noexcept:
   current(position, mass, momentum),
   previous(current),
   interpolated(current)
{
}
三个数据成员“current”、“previous”和“interpolated”属于physicstate类型,其构造函数在下面详细介绍

constexpr PhysicsState::PhysicsState(Vec2f position, float mass, Vec2f momentum) noexcept:
   mass(mass),
   inverseMass(MathUtils::computeInverse(mass)),
   position(position),
   momentum(momentum),
   externalForce(ZERO_VECTOR)
{
}
computeInverse的签名如下:

template<typename T>
constexpr T computeInverse(T value) noexcept
main()
编译和运行时不显示任何消息和突出显示。

如果您能深入了解此问题,我们将不胜感激。

如果intellisense已编译,请忽略它。
它有时只是发出错误的警告

智能感知远非完美。从来没有,也很可能永远不会。当你收到混杂的信息时,相信编译器。啊,我想答案并不像我希望的那么有趣。。。但是,唉,这似乎是最简单和最可能的解释,我忽略了TelliSense是一个编译器的模拟。这通常是错误的(如你所见)。别理它,我现在有一个宏大的问题。。。我应该把它拿下来,还是什么?XDNo。如果其他人有这种行为,他/她可能会在这里找到答案。