From 3c5c0c2287203b61acc94bb83fac1b91ae290007 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 5 Oct 2017 10:08:53 +0100 Subject: [PATCH] Allow CDHashMaps for objects without default constructors (#1092) This is a patch, originally from mdeters/cdhashmap-default-constructibility that allows CDHashMaps to be declared for objects that don't have default constructors. --- src/context/cdhashmap.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/context/cdhashmap.h b/src/context/cdhashmap.h index 5b7a4dab1..82aa90891 100644 --- a/src/context/cdhashmap.h +++ b/src/context/cdhashmap.h @@ -180,7 +180,7 @@ public: bool allocatedInCMM = false) : ContextObj(allocatedInCMM, context), d_key(key), - d_data(), + d_data(data), d_map(NULL), d_noTrash(allocatedInCMM) { @@ -343,7 +343,7 @@ public: Element* obj; if(i == d_map.end()) {// create new object obj = new(true) Element(d_context, this, k, Data()); - d_map[k] = obj; + d_map.insert(std::make_pair(k, obj)); } else { obj = (*i).second; } @@ -355,7 +355,7 @@ public: if(i == d_map.end()) {// create new object Element* obj = new(true) Element(d_context, this, k, d); - d_map[k] = obj; + d_map.insert(std::make_pair(k, obj)); return true; } else { (*i).second->set(d); @@ -392,7 +392,7 @@ public: Element* obj = new(true) Element(d_context, this, k, d, true /* atLevelZero */); - d_map[k] = obj; + d_map.insert(std::make_pair(k, obj)); } // FIXME: no erase(), too much hassle to implement efficiently... -- 2.30.2