Common: Drop fallback path for HeterogeneousContainers

This commit is contained in:
Stenzek
2023-09-05 21:03:49 +10:00
parent 58b4946fb9
commit 391307efaa
6 changed files with 74 additions and 162 deletions

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
/**
@@ -47,8 +47,6 @@ struct transparent_string_less
};
} // namespace detail
// This requires C++20, so fallback to ugly heap allocations if we don't have it.
#if __cplusplus >= 202002L
template<typename ValueType>
using UnorderedStringMap =
std::unordered_map<std::string, ValueType, detail::transparent_string_hash, detail::transparent_string_equal>;
@@ -60,95 +58,9 @@ using UnorderedStringSet =
using UnorderedStringMultiSet =
std::unordered_multiset<std::string, detail::transparent_string_hash, detail::transparent_string_equal>;
template<typename KeyType, typename ValueType>
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::const_iterator
UnorderedStringMapFind(const UnorderedStringMap<ValueType>& map, const KeyType& key)
{
return map.find(key);
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::iterator
UnorderedStringMapFind(UnorderedStringMap<ValueType>& map, const KeyType& key)
{
return map.find(key);
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::const_iterator
UnorderedStringMultiMapFind(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.find(key);
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::const_iterator,
typename UnorderedStringMultimap<ValueType>::const_iterator>
UnorderedStringMultiMapEqualRange(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.equal_range(key);
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::iterator
UnorderedStringMultiMapFind(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.find(key);
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::iterator,
typename UnorderedStringMultimap<ValueType>::iterator>
UnorderedStringMultiMapEqualRange(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.equal_range(key);
}
#else
template<typename ValueType>
using UnorderedStringMap = std::unordered_map<std::string, ValueType>;
template<typename ValueType>
using UnorderedStringMultimap = std::unordered_multimap<std::string, ValueType>;
using UnorderedStringSet = std::unordered_set<std::string>;
using UnorderedStringMultiSet = std::unordered_multiset<std::string>;
template<typename KeyType, typename ValueType>
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::const_iterator
UnorderedStringMapFind(const UnorderedStringMap<ValueType>& map, const KeyType& key)
{
return map.find(std::string(key));
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::iterator
UnorderedStringMapFind(UnorderedStringMap<ValueType>& map, const KeyType& key)
{
return map.find(std::string(key));
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::const_iterator
UnorderedStringMultiMapFind(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.find(std::string(key));
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::const_iterator,
typename UnorderedStringMultimap<ValueType>::const_iterator>
UnorderedStringMultiMapEqualRange(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.equal_range(std::string(key));
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::iterator
UnorderedStringMultiMapFind(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.find(std::string(key));
}
template<typename KeyType, typename ValueType>
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::iterator,
typename UnorderedStringMultimap<ValueType>::iterator>
UnorderedStringMultiMapEqualRange(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
{
return map.equal_range(std::string(key));
}
#endif
template<typename ValueType>
using StringMap = std::map<std::string, ValueType, detail::transparent_string_less>;
template<typename ValueType>
using StringMultiMap = std::multimap<std::string, ValueType, detail::transparent_string_less>;
using StringSet = std::set<std::string, detail::transparent_string_less>;
using StringMultiSet = std::multiset<std::string, detail::transparent_string_less>;
using StringMultiSet = std::multiset<std::string, detail::transparent_string_less>;