namespace "std" has no member "clamp"

16,703

You would have to use the /std:c++latest switch to enable C++17 additions to the standard.

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

Share:
16,703

Related videos on Youtube

jeohd
Author by

jeohd

Manager at https://portfolioinsight.io/

Updated on September 15, 2022

Comments

  • jeohd
    jeohd over 1 year

    VS2015 wont compile my code, says namespace "std" has no member "clamp", although intellisense picks it up just fine and tells me the parameters and return value. Yes, i have included the 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);
    }
    
    • Kevin
      Kevin about 7 years
      std::clamp looks to be C++17 exclusive. Do you have your compiler flags set to compile C++17?
    • ShadowRanger
      ShadowRanger about 7 years
      Visual Studio 2015 claims little support for C++17 features, I wouldn't be surprised if it didn't have std::clamp even if you asked for C++17 support.