Add unity build support
This commit is contained in:
@@ -39,13 +39,24 @@ namespace Nz
|
||||
inline bool HashAppend(AbstractHash* hash, const std::string_view& v);
|
||||
template<typename T> void HashCombine(std::size_t& seed, const T& v);
|
||||
template<typename T> bool IsPowerOfTwo(T value);
|
||||
template<typename K, typename V> V& Retrieve(std::unordered_map<K, V>& map, const K& key);
|
||||
template<typename K, typename V> const V& Retrieve(const std::unordered_map<K, V>& map, const K& key);
|
||||
template<typename T> T ReverseBits(T integer);
|
||||
template<typename To, typename From> To SafeCast(From&& value);
|
||||
template<typename T, typename U>std::unique_ptr<T> StaticUniquePointerCast(std::unique_ptr<U>&& ptr);
|
||||
template<typename T> constexpr auto UnderlyingCast(T value) -> std::underlying_type_t<T>;
|
||||
|
||||
template<typename T>
|
||||
struct AlwaysFalse : std::false_type {};
|
||||
|
||||
// Helper for std::visit
|
||||
template<typename... Ts> struct Overloaded : Ts...
|
||||
{
|
||||
using Ts::operator()...;
|
||||
};
|
||||
|
||||
template<typename... Ts> Overloaded(Ts...) -> Overloaded<Ts...>;
|
||||
|
||||
template<typename... Args>
|
||||
struct OverloadResolver
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user