Garmaine Staff asked 2 years ago
Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 hours ago.

I'm trying to use clamp, but can't find it

A summary example

File: test.h

#ifndef DEMO_H
#define DEMO_H

#include <algorithm>

namespace demo {

   typedef float real_t;
   class test {
           void start();
           real_t x = 10.90;
           real_t y = 2.10;

#endif //DEMO_H

File: test.cpp

#include "test.h"

using namespace demo;

void test::start() {
    const int& p = std::clamp(x, 0,  y);

VSC error, compile using scons:

no overloaded function instance "std :: clamp" matches the argument list - argument types are: (real_t, int, real_t)

Thanks a lot!