Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

namespace "std" has no member "clamp"

Tags:

c++

std

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);
}
like image 245
jeohd Avatar asked Feb 01 '17 05:02

jeohd


People also ask

What does std :: clamp do?

std::clamp in C++ 17Clamps a variable to a given range[high – low]. If num > high, num is assigned high. If num < low, num is assigned low. If num is already clamped, no modifications.

What library is clamp in C++?

The clamp() function in C++ boost library is found under the header 'boost/algorithm/clamp.


1 Answers

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/

like image 56
Bo Persson Avatar answered Sep 17 '22 19:09

Bo Persson