diff options
author | Martin <martin.brain@cs.ox.ac.uk> | 2017-10-05 10:08:53 +0100 |
---|---|---|
committer | Andres Noetzli <andres.noetzli@gmail.com> | 2017-10-05 02:08:53 -0700 |
commit | 3c5c0c2287203b61acc94bb83fac1b91ae290007 (patch) | |
tree | b95533ffbe6b6b25855de9ec6f99c1f7af06e9c7 /src/context | |
parent | a63efde07c65a3a0499f85c13757643ff52f154c (diff) |
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.
Diffstat (limited to 'src/context')
-rw-r--r-- | src/context/cdhashmap.h | 8 |
1 files 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... |