Add unity build support

This commit is contained in:
Jérôme Leclercq
2022-03-15 08:26:57 +01:00
parent 0a4fd8f56d
commit 6bd9f1a9e4
109 changed files with 964 additions and 680 deletions

View File

@@ -363,6 +363,38 @@ namespace Nz
return (value & (value - 1)) == 0;
}
/*!
* \ingroup core
* \brief Helper function to retrieve a key in a map which has to exist
* \return Value associated with key
*
* \param map Map
* \param key Key, has to exist in map
*/
template<typename K, typename V>
V& Retrieve(std::unordered_map<K, V>& map, const K& key)
{
auto it = map.find(key);
assert(it != map.end());
return it->second;
}
/*!
* \ingroup core
* \brief Helper function to retrieve a key in a map which has to exist
* \return Value associated with key
*
* \param map Map
* \param key Key, has to exist in map
*/
template<typename K, typename V>
const V& Retrieve(const std::unordered_map<K, V>& map, const K& key)
{
auto it = map.find(key);
assert(it != map.end());
return it->second;
}
/*!
* \ingroup core
* \brief Reverse the bit order of the integer
@@ -472,6 +504,12 @@ namespace Nz
#endif
}
template<typename T, typename U>
std::unique_ptr<T> StaticUniquePointerCast(std::unique_ptr<U>&& ptr)
{
return std::unique_ptr<T>(SafeCast<T*>(ptr.release()));
}
template<typename T>
constexpr auto UnderlyingCast(T value) -> std::underlying_type_t<T>
{