Boost 1.50.0ã§ãBoost Algorithmã©ã¤ãã©ãªãæ°ãã«è¿½å ããã¾ãããããããããã¤ãç´¹ä»ãã¦ãããã¨æãã¾ãã ä»åã¯clamp()ã§ãã clamp()ã¯ãæå°å¤ã¨æ大å¤ãè¨å®ããä¸ã§å¤ã渡ãã¨ããã®ç¯å²å ã«å¤ãåãã¦ãããé¢æ°ã§ãã æå³çã«ã¯ãmin(max(minval, x), maxval)ã¨åãã«ãªãã¾ãã 以ä¸ã®ä¾ã§ã¯ãå¤ã0ãã10ã®ç¯å²å¤ã ã£ãããã®ç¯å²ã«åãããã¨ãããã¨ããã¦ãã¾ãã #include <iostream> #include <boost/algorithm/clamp.hpp> int main() { using boost::algorithm::clamp; int x = 11; x = clamp(x, 0, 10); int y = -1; y = clamp(y, 0, 10); std::cout << x
{{#tags}}- {{label}}
{{/tags}}