Core/Algorithm: Add BitCount function
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <climits>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -70,6 +71,17 @@ namespace Nz
|
||||
return Detail::ApplyImplMethod(object, std::forward<F>(fn), std::forward<Tuple>(t), std::make_index_sequence<tSize>());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \brief Returns the number of bits occupied by the type T
|
||||
* \return Number of bits occupied by the type
|
||||
*/
|
||||
template<typename T>
|
||||
constexpr std::size_t BitCount()
|
||||
{
|
||||
return CHAR_BIT * sizeof(T);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \brief Computes the hash of a hashable object
|
||||
|
||||
Reference in New Issue
Block a user