aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-01-15 11:02:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-01-15 11:02:15 +0200
commitc59ce78f409db8bb53042380903c8ece8b8fbd28 (patch)
tree2a1ec6c6aaab3e6b8c00b80d07d0386ff14838ba /build
parentc2339b07fb683355c6a6155ec312b1616167614e (diff)
Allow specifying prefix_map delimiter as template argument
Diffstat (limited to 'build')
-rw-r--r--build/prefix_map37
-rw-r--r--build/prefix_map.txx4
2 files changed, 31 insertions, 10 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>
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 <typename M>
- auto prefix_map_impl<M>::
+ auto prefix_map_common<M>::
find (const key_type& k) -> std::pair<iterator, iterator>
{
std::pair<iterator, iterator> r;
@@ -23,7 +23,7 @@ namespace build
}
template <typename M>
- auto prefix_map_impl<M>::
+ auto prefix_map_common<M>::
find (const key_type& k) const -> std::pair<const_iterator, const_iterator>
{
std::pair<const_iterator, const_iterator> r;