mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 22:17:51 +00:00
Pull Is() out of castable and into a new TypeInfo
Allows you to query type inheritance without having an instance of the type. Also add TypeInfo::name. Helpful for decent error messages. Strings can be removed from NDEBUG builds if we consider them too large. Change-Id: Ie501b37f46e63d956cc020f8c9b68e91737472f0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42920 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Reviewed-by: James Price <jrprice@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
5cfd4f5a07
commit
e879143801
@@ -67,14 +67,14 @@ class DataMap {
|
||||
void Put(std::unique_ptr<T>&& data) {
|
||||
static_assert(std::is_base_of<Data, T>::value,
|
||||
"T does not derive from Data");
|
||||
map_[ClassID::Of<T>()] = std::move(data);
|
||||
map_[&TypeInfo::Of<T>()] = std::move(data);
|
||||
}
|
||||
|
||||
/// @returns a pointer to the Data placed into the DataMap with a call to
|
||||
/// Put()
|
||||
template <typename T>
|
||||
T const* Get() const {
|
||||
auto it = map_.find(ClassID::Of<T>());
|
||||
auto it = map_.find(&TypeInfo::Of<T>());
|
||||
if (it == map_.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class DataMap {
|
||||
PutAll(std::forward<Tn>(remainder)...);
|
||||
}
|
||||
|
||||
std::unordered_map<ClassID, std::unique_ptr<Data>> map_;
|
||||
std::unordered_map<const TypeInfo*, std::unique_ptr<Data>> map_;
|
||||
};
|
||||
|
||||
/// Interface for Program transforms
|
||||
|
||||
Reference in New Issue
Block a user