diff options
Diffstat (limited to 'cli-examples/features/driver.cxx')
-rw-r--r-- | cli-examples/features/driver.cxx | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/cli-examples/features/driver.cxx b/cli-examples/features/driver.cxx index a6299b9..fc364a0 100644 --- a/cli-examples/features/driver.cxx +++ b/cli-examples/features/driver.cxx @@ -2,6 +2,7 @@ // author : Boris Kolpackov <boris@codesynthesis.com> // license : MIT; see accompanying LICENSE file +#include <utility> // pair #include <iostream> #include <iterator> #include <algorithm> @@ -45,13 +46,27 @@ main (int argc, char* argv[]) // --map | -m // - typedef map<std::string, bool> str_map; - const str_map& m = o.map (); - str_map::const_iterator i (m.find ("a")); + { + typedef map<string, bool> str_map; + const str_map& m = o.map (); + str_map::const_iterator i (m.find ("a")); - if (i != m.end ()) - cerr << "value for the 'a' key: " << i->second << endl; + if (i != m.end ()) + cerr << "value for the 'a' map key: " << i->second << endl; + } + // --multimap + // + { + typedef multimap<string, int> str_multimap; + const str_multimap& m = o.multimap (); + + pair<str_multimap::const_iterator, str_multimap::const_iterator> r ( + m.equal_range ("a")); + + for (str_multimap::const_iterator i (r.first); i != r.second; ++i) + cerr << "value for the 'a' multimap key: " << i->second << endl; + } } catch (const cli::exception& e) { |