aboutsummaryrefslogtreecommitdiff
path: root/build/prefix_map
diff options
context:
space:
mode:
Diffstat (limited to 'build/prefix_map')
-rw-r--r--build/prefix_map37
1 files changed, 29 insertions, 8 deletions
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 <typename M>
- 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<value_type> init,
- typename compare_type::char_type delimiter)
+ prefix_map_common (std::initializer_list<value_type> init,
+ char_type delimiter)
: map_type (std::move (init), compare_type (delimiter)) {}
std::pair<iterator, iterator>
@@ -106,12 +107,32 @@ namespace build
find (const key_type&) const;
};
- template <typename K, typename T>
- using prefix_map = prefix_map_impl<std::map<K, T, compare_prefix<K>>>;
+ template <typename M, typename prefix_map_common<M>::char_type D = 0>
+ struct prefix_map_impl: prefix_map_common<M>
+ {
+ typedef typename prefix_map_common<M>::value_type value_type;
+
+ prefix_map_impl (): prefix_map_common<M> (D) {}
+ prefix_map_impl (std::initializer_list<value_type> init)
+ : prefix_map_common<M> (std::move (init), D) {}
+ };
+
+ template <typename M>
+ struct prefix_map_impl<M, 0>: prefix_map_common<M>
+ {
+ using prefix_map_common<M>::prefix_map_common;
+ };
+
+ template <typename K,
+ typename T,
+ typename compare_prefix<K>::char_type D = 0>
+ using prefix_map = prefix_map_impl<std::map<K, T, compare_prefix<K>>, D>;
- template <typename K, typename T>
+ template <typename K,
+ typename T,
+ typename compare_prefix<K>::char_type D = 0>
using prefix_multimap =
- prefix_map_impl<std::multimap<K, T, compare_prefix<K>>>;
+ prefix_map_impl<std::multimap<K, T, compare_prefix<K>>, D>;
}
#include <build/prefix_map.txx>