Handout
This commit is contained in:
17
kernel/utils/size.h
Normal file
17
kernel/utils/size.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*! \file
|
||||
* \brief Template function to determine the length of an array
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../types.h"
|
||||
|
||||
/* \brief Helper to retrieve the number of elements in an array
|
||||
* (Warning: template magic)
|
||||
* \param Array
|
||||
* \return Number of elements
|
||||
*/
|
||||
template <class T, size_t N>
|
||||
constexpr size_t size(T (& /*unused*/)[N]) {
|
||||
return N;
|
||||
}
|
||||
Reference in New Issue
Block a user