From 50cd8941965ddd3017f01bc2e8ccfb50adb7cf80 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 29 Nov 2020 09:58:09 -0500 Subject: [PATCH] Add example with default parameters --- examples/allmaps.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/allmaps.cc b/examples/allmaps.cc index af2dfc7..6259624 100644 --- a/examples/allmaps.cc +++ b/examples/allmaps.cc @@ -4,7 +4,7 @@ #include "parallel_hashmap/phmap.h" template -void test_set(F &f) +void test_set(const F &f) { Set s; typename Set::iterator it; @@ -30,6 +30,7 @@ int main(int, char **) auto make_2int = [](int i) { return std::make_pair(i, i); }; auto make_2string = [](int i) { return std::make_pair(std::to_string(i), std::to_string(i)); }; + test_set>(make_int); test_set>(make_string); @@ -54,4 +55,14 @@ int main(int, char **) test_set>(make_2int); test_set>(make_2string); + + // example of using default parameters in order to specify the mutex type + using Map = phmap::parallel_flat_hash_map, + phmap::priv::hash_default_eq, + std::allocator>, + 4, + std::mutex>; + auto make_2size_t = [](size_t i) { return std::make_pair(i, i); }; + test_set(make_2size_t); }