#pragma once namespace meta { // Update if different ========================================================= template bool updateIfDifferent (T& lhs, const T& rhs) { if (lhs == rhs) return false; lhs = rhs; return true; } template bool updateIfDifferent (T& lhs, const T&& rhs) { if (lhs == rhs) return false; lhs = rhs; return true; } // Protected math call ========================================================= template T exp(T exponent) { static const T maxExponent = std::nextafter(std::log(std::numeric_limits::max()), T(0)); static const T maxValue = std::exp(maxExponent); return (exponent < maxExponent) ? std::exp(exponent) : maxValue; } template T min(T a, T b) { return (a < b) ? a : b; } template T max(T a, T b) { return (a > b) ? a : b; } template T clamp(T value, T minValue, T maxValue) { return max(min(value, maxValue), minValue); } } // namespace