【问题标题】:namespace "std" has no member "clamp"命名空间“std”没有成员“clamp”
【发布时间】:2021-03-01 16:07:26
【问题描述】:

VS2015 不会编译我的代码,说命名空间“std”没有成员“clamp”,尽管智能感知很好地把它捡起来并告诉我参数和返回值。 是的,我已经包含了标题。

#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::clamp 看起来是 C++17 独有的。您是否将编译器标志设置为编译 C++17?
  • Visual Studio 2015 claims little support for C++17 features,即使您要求 C++17 支持,如果它没有 std::clamp 我也不会感到惊讶。
  • 您可能想检查一下是否有标头的实验版本。
  • 自VS2015.3起Clamp为supported
  • 现在有同样的问题。太奇怪了……

标签: c++ std


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-13
    • 2012-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 1970-01-01
    • 2023-04-08
    相关资源
    最近更新 更多