X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fcollection.h;h=d5e0806afeebad9fbfa2f043ef80d3ef9bc64878;hp=5dd2fe67ff2769083532605e2b33bd5fe3c9dec1;hb=e249d648f6393fbb4b74e76c2a7b9eee9f1187f1;hpb=b48d1eb90c63e70b03519923dab5e123b11d91a4 diff --git a/source/collection.h b/source/collection.h index 5dd2fe6..d5e0806 100644 --- a/source/collection.h +++ b/source/collection.h @@ -151,9 +151,16 @@ public: 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 + 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::Type>(); + } /// Returns the name of an item in the collection. template