命名空间 "std" 没有成员 "clamp"

namespace "std" has no member "clamp"

VS2015 不会编译我的代码,说命名空间 "std" 没有成员 "clamp",尽管 intellisense 可以很好地识别它并告诉我参数和 return 值。 是的,我包括了 header.

#include <Math/Matrix3D.h>
#include <glm.hpp>
#include <gtx/transform.hpp>
#include <Utils/Clock.h>

#include <algorithm>

void somefunc()
{
viewPos.y = std::clamp(viewPos.y, -0.95f, 0.95f);
}

您必须使用 /std:c++latest 开关来启用标准的 C++17 添加。

https://blogs.msdn.microsoft.com/vcblog/2016/06/07/standards-version-switches-in-the-compiler/