diff --git a/extras/AssociativeContainers/map.hpp b/extras/AssociativeContainers/map.hpp index 02ccd5d..dc54c14 100644 --- a/extras/AssociativeContainers/map.hpp +++ b/extras/AssociativeContainers/map.hpp @@ -33,4 +33,7 @@ class Map size_t max_size() const { return this->map.max_size(); } void clear() noexcept { this->map.clear(); } + + size_t count(K const& key ) const { return this->map.count(key); } + }; diff --git a/source/stdcpp/map.d b/source/stdcpp/map.d index a04c24f..10d8318 100644 --- a/source/stdcpp/map.d +++ b/source/stdcpp/map.d @@ -33,7 +33,7 @@ module stdcpp.map; ref Value at( ref const Key key); - ref Value at(const Key key) + extern(D) ref Value at(const Key key) { return this.at(key); } @@ -43,4 +43,11 @@ module stdcpp.map; size_t max_size() const; void clear() nothrow; + + size_t count(ref const Key key) const; + + extern(D) size_t count(const Key key) + { + return this.count(key); + } } \ No newline at end of file diff --git a/source/stdcpp/test/map.d b/source/stdcpp/test/map.d index 330b760..0d38aca 100644 --- a/source/stdcpp/test/map.d +++ b/source/stdcpp/test/map.d @@ -22,4 +22,5 @@ unittest mymap.clear(); assert(mymap.size == 0); assert(mymap.empty == 1); + assert(mymap.count(1) == 1); // key 1 exists once }