@@ -128,7 +128,7 @@ namespace cereal
128
128
static bool exists ( std::type_index const & baseIndex, std::type_index const & derivedIndex )
129
129
{
130
130
// First phase of lookup - match base type index
131
- auto & baseMap = StaticObject<PolymorphicCasters>::getInstance ().map ;
131
+ auto const & baseMap = StaticObject<PolymorphicCasters>::getInstance ().map ;
132
132
auto baseIter = baseMap.find ( baseIndex );
133
133
if (baseIter == baseMap.end ())
134
134
return false ;
@@ -151,7 +151,7 @@ namespace cereal
151
151
static std::vector<PolymorphicCaster const *> const & lookup ( std::type_index const & baseIndex, std::type_index const & derivedIndex, F && exceptionFunc )
152
152
{
153
153
// First phase of lookup - match base type index
154
- auto & baseMap = StaticObject<PolymorphicCasters>::getInstance ().map ;
154
+ auto const & baseMap = StaticObject<PolymorphicCasters>::getInstance ().map ;
155
155
auto baseIter = baseMap.find ( baseIndex );
156
156
if ( baseIter == baseMap.end () )
157
157
exceptionFunc ();
@@ -161,7 +161,7 @@ namespace cereal
161
161
auto derivedIter = derivedMap.find ( derivedIndex );
162
162
if ( derivedIter == derivedMap.end () )
163
163
exceptionFunc ();
164
-
164
+
165
165
return derivedIter->second ;
166
166
}
167
167
@@ -218,6 +218,7 @@ namespace cereal
218
218
assuming dynamic type information is available */
219
219
PolymorphicVirtualCaster ()
220
220
{
221
+ const auto lock = StaticObject<PolymorphicCasters>::lock ();
221
222
auto & baseMap = StaticObject<PolymorphicCasters>::getInstance ().map ;
222
223
auto baseKey = std::type_index (typeid (Base));
223
224
auto lb = baseMap.lower_bound (baseKey);
@@ -236,7 +237,7 @@ namespace cereal
236
237
auto checkRelation = [](std::type_index const & baseInfo, std::type_index const & derivedInfo)
237
238
{
238
239
const bool exists = PolymorphicCasters::exists ( baseInfo, derivedInfo );
239
- return std::make_pair ( exists, exists ? PolymorphicCasters::lookup ( baseInfo, derivedInfo, [](){} ) :
240
+ return std::make_pair ( exists, exists ? PolymorphicCasters::lookup ( baseInfo, derivedInfo, [](){} ) :
240
241
std::vector<PolymorphicCaster const *>{} );
241
242
};
242
243
@@ -409,6 +410,7 @@ namespace cereal
409
410
InputBindingCreator ()
410
411
{
411
412
auto & map = StaticObject<InputBindingMap<Archive>>::getInstance ().map ;
413
+ auto lock = StaticObject<InputBindingMap<Archive>>::lock ();
412
414
auto key = std::string (binding_name<T>::name ());
413
415
auto lb = map.lower_bound (key);
414
416
0 commit comments