types: add param_count function
This commit is contained in:
parent
06739046e0
commit
1c9d446d87
17
types.hpp
17
types.hpp
@ -99,6 +99,23 @@ namespace util {
|
|||||||
{
|
{
|
||||||
typedef T type;
|
typedef T type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///------------------------------------------------------------------------
|
||||||
|
/// count the number of parameters we are given. useful for counting
|
||||||
|
/// arguments in variadic macros (ie, sizeof... (__VA_ARGS__))
|
||||||
|
template <typename ...T>
|
||||||
|
constexpr size_t
|
||||||
|
param_count (const T... t)
|
||||||
|
{
|
||||||
|
// prevent unused variable warnings by never forwarding recursively
|
||||||
|
// ideally we'd use void casting, but it doesn't work for parameter
|
||||||
|
// packs
|
||||||
|
if (false)
|
||||||
|
return param_count (t...);
|
||||||
|
|
||||||
|
return sizeof... (t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user