BLI: add non-const lookup methods for StringMap

This commit is contained in:
Jacques Lucke 2019-09-13 12:28:19 +02:00
parent 08539312b2
commit f85ea4ae3c
1 changed files with 10 additions and 0 deletions

View File

@ -248,6 +248,11 @@ template<typename T, typename Allocator = GuardedAllocator> class StringMap {
ITER_SLOTS_END(offset);
}
T &lookup(StringRef key)
{
return const_cast<T &>(const_cast<const StringMap *>(this)->lookup(key));
}
/**
* Get a pointer to the value corresponding to the key. Return nullptr, if the key does not
* exist.
@ -266,6 +271,11 @@ template<typename T, typename Allocator = GuardedAllocator> class StringMap {
ITER_SLOTS_END(offset);
}
T *lookup_ptr(StringRef key)
{
return const_cast<T *>(const_cast<const StringMap *>(this)->lookup_ptr(key));
}
/**
* Get a copy of the value corresponding to the key. If the key does not exist, return the
* default value.