Commit fd5aa4a3 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

core: move usefull template function

parent 9105491f
Pipeline #33344 passed with stage
in 1 minute and 14 seconds
......@@ -93,33 +93,6 @@ status_string(const status s) noexcept
return str[static_cast<int>(s)];
}
template<class C>
constexpr int
length(const C& c) noexcept
{
return static_cast<int>(c.size());
}
template<class T, size_t N>
constexpr int
length(const T (&array)[N]) noexcept
{
(void)array;
return static_cast<int>(N);
}
template<typename Identifier>
constexpr Identifier
undefined() noexcept
{
static_assert(
std::is_enum<Identifier>::value,
"Identifier must be a enumeration: enum class id : unsigned {};");
return static_cast<Identifier>(0);
}
enum class editor_id : u64;
enum class cluster_id : u64;
......
......@@ -138,6 +138,33 @@ to_unsigned(Integer value)
return static_cast<typename std::make_unsigned<Integer>::type>(value);
}
template<class C>
constexpr int
length(const C& c) noexcept
{
return static_cast<int>(c.size());
}
template<class T, size_t N>
constexpr int
length(const T (&array)[N]) noexcept
{
(void)array;
return static_cast<int>(N);
}
template<typename Identifier>
constexpr Identifier
undefined() noexcept
{
static_assert(
std::is_enum<Identifier>::value,
"Identifier must be a enumeration: enum class id : unsigned {};");
return static_cast<Identifier>(0);
}
/*****************************************************************************
*
* Return status of many function
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment