The std::lerp is a C++20 mathematical function that handles linear interpolation (and extrapolation) for floating-point types.
The function takes three arguments: the two boundary values and an interpolation factor. The implementation will correctly handle infinities and boundary values for the interpolation factor.
Compiler Explorer link: https://compiler-explorer.com/z/xdvT4434Y