11#ifndef M5_UTILITY_STL_EXTENSION_HPP
12#define M5_UTILITY_STL_EXTENSION_HPP
23constexpr auto size(
const C& c) ->
decltype(c.size())
29template <
typename T,
size_t N>
30constexpr auto size(
const T (&)[N])
noexcept ->
size_t
43#if __cplusplus >= 201703L
47constexpr const T&
clamp(
const T& v,
const T& low,
const T& high)
49 return (v < low) ? low : (high < v) ? high : v;
52template <
class T,
class Compare>
53constexpr const T& clamp(
const T& v,
const T& low,
const T& high, Compare comp)
55 return comp(v, low) ? low : comp(high, v) ? high : v;
67constexpr inline typename std::underlying_type<E>::type
to_underlying(
const E e)
noexcept
69 return static_cast<typename std::underlying_type<E>::type
>(e);
constexpr auto size(const C &c) -> decltype(c.size())
Like std::size C++17 or later.(for container)
Definition extension.hpp:23
constexpr const T & clamp(const T &v, const T &low, const T &high)
Like std::clamp C++17 or later.
Definition extension.hpp:47
constexpr std::underlying_type< E >::type to_underlying(const E e) noexcept
Converts an enumeration to its underlying type.(Like std::to_underlying C++23 or later)
Definition extension.hpp:67
Top level namespace of M5.
Definition base64.cpp:39
STL compatibility functions and classes.