common: common_funcs: Add Size helper function.
This commit is contained in:
parent
66f2ad716b
commit
02c2b28cd0
@ -136,4 +136,19 @@ namespace Common {
|
|||||||
return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24;
|
return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// std::size() does not support zero-size C arrays. We're fixing that.
|
||||||
|
template <class C>
|
||||||
|
constexpr auto Size(const C& c) -> decltype(c.size()) {
|
||||||
|
return std::size(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class C>
|
||||||
|
constexpr std::size_t Size(const C& c) {
|
||||||
|
if constexpr (sizeof(C) == 0) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return std::size(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
Loading…
Reference in New Issue
Block a user