Checking item existence without type information is not particularly
useful, since there's no guarantee that the object can be used for its
intended purpose.
delete *i;
}
-bool Collection::contains(const std::string &n) const
-{
- return items.count(n);
-}
-
Collection::Loader::Loader(Collection &c):
coll(c)
return result;
}
- /** Checks whether a name exists in the collection. Does not care about the
- type of the object. */
- bool contains(const std::string &n) const;
+ /// Checks whether a typed object exists in the collection.
+ template<typename T>
+ bool contains(const std::string &name) const
+ {
+ ItemMap::const_iterator i = items.find(name);
+ if(i==items.end())
+ return false;
+
+ return i->second.check_type<typename RemoveConst<T>::Type>();
+ }
/// Returns the name of an item in the collection.
template<typename T>