blob: 7fef65ba47670f52745235e4bb9039635fc46b66 [file]
// Part of the Crubit project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
use inline_cpp_macro::{global_cpp, inline_cpp};
global_cpp! {
#include <algorithm>
}
/// Calls an instantiated C++ standard library template.
pub fn clamp_value(val: f32, min: f32, max: f32) -> f32 {
let clamp = inline_cpp! {
(float val, float min, float max) -> float {
return std::clamp<float>(val, min, max);
}
};
clamp(val, min, max)
}