Core/Algorithm: Add BitCount function

This commit is contained in:
Lynix
2016-11-18 01:13:30 +01:00
parent 2ed65e60e1
commit 359b5e6c3a
4 changed files with 24 additions and 11 deletions

View File

@@ -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