]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_json: map type can handle 2 or 3 template arguments
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 3 Apr 2017 22:11:27 +0000 (15:11 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 30 May 2017 20:24:45 +0000 (13:24 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/common/ceph_json.h

index 18cf06fd4f198e4e88496fea3ec5f5268964de75..6c9e3b4174dfcab932d4044801b8cd99edaba5e7 100644 (file)
@@ -210,8 +210,8 @@ void decode_json_obj(vector<T>& l, JSONObj *obj)
   }
 }
 
-template<class K, class V>
-void decode_json_obj(map<K, V>& m, JSONObj *obj)
+template<class K, class V, class C = std::less<K> >
+void decode_json_obj(map<K, V, C>& m, JSONObj *obj)
 {
   m.clear();
 
@@ -384,11 +384,11 @@ static void encode_json(const char *name, const std::vector<T>& l, ceph::Formatt
   f->close_section();
 }
 
-template<class K, class V>
-static void encode_json(const char *name, const std::map<K, V>& m, ceph::Formatter *f)
+template<class K, class V, class C = std::less<K> >
+static void encode_json(const char *name, const std::map<K, V, C>& m, ceph::Formatter *f)
 {
   f->open_array_section(name);
-  for (typename std::map<K, V>::const_iterator i = m.begin(); i != m.end(); ++i) {
+  for (typename std::map<K, V, C>::const_iterator i = m.begin(); i != m.end(); ++i) {
     f->open_object_section("entry");
     encode_json("key", i->first, f);
     encode_json("val", i->second, f);