From c59ce78f409db8bb53042380903c8ece8b8fbd28 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 15 Jan 2015 11:02:15 +0200 Subject: Allow specifying prefix_map delimiter as template argument --- build/prefix_map | 37 +++++++++++++++++++++++++++++-------- build/prefix_map.txx | 4 ++-- 2 files changed, 31 insertions(+), 10 deletions(-) (limited to 'build') diff --git a/build/prefix_map b/build/prefix_map index 13388b2..f911d26 100644 --- a/build/prefix_map +++ b/build/prefix_map @@ -81,22 +81,23 @@ namespace build // 'foobar' as having a prefix 'foo'. // template - struct prefix_map_impl: M + struct prefix_map_common: M { typedef M map_type; typedef typename map_type::key_type key_type; typedef typename map_type::value_type value_type; typedef typename map_type::key_compare compare_type; + typedef typename compare_type::char_type char_type; typedef typename map_type::iterator iterator; typedef typename map_type::const_iterator const_iterator; explicit - prefix_map_impl (typename compare_type::char_type delimiter) + prefix_map_common (char_type delimiter) : map_type (compare_type (delimiter)) {} - prefix_map_impl (std::initializer_list init, - typename compare_type::char_type delimiter) + prefix_map_common (std::initializer_list init, + char_type delimiter) : map_type (std::move (init), compare_type (delimiter)) {} std::pair @@ -106,12 +107,32 @@ namespace build find (const key_type&) const; }; - template - using prefix_map = prefix_map_impl>>; + template ::char_type D = 0> + struct prefix_map_impl: prefix_map_common + { + typedef typename prefix_map_common::value_type value_type; + + prefix_map_impl (): prefix_map_common (D) {} + prefix_map_impl (std::initializer_list init) + : prefix_map_common (std::move (init), D) {} + }; + + template + struct prefix_map_impl: prefix_map_common + { + using prefix_map_common::prefix_map_common; + }; + + template ::char_type D = 0> + using prefix_map = prefix_map_impl>, D>; - template + template ::char_type D = 0> using prefix_multimap = - prefix_map_impl>>; + prefix_map_impl>, D>; } #include diff --git a/build/prefix_map.txx b/build/prefix_map.txx index 17a8ca0..91f8e0a 100644 --- a/build/prefix_map.txx +++ b/build/prefix_map.txx @@ -5,7 +5,7 @@ namespace build { template - auto prefix_map_impl:: + auto prefix_map_common:: find (const key_type& k) -> std::pair { std::pair r; @@ -23,7 +23,7 @@ namespace build } template - auto prefix_map_impl:: + auto prefix_map_common:: find (const key_type& k) const -> std::pair { std::pair r; -- cgit v1.1