fix null range instace issue

This commit is contained in:
Christian Zimmermann 2018-07-29 14:35:53 +02:00
parent 1523fa024e
commit 15f4f38e48

View file

@ -13,27 +13,31 @@ namespace MultiArrayTools
* SingleRange * * SingleRange *
********************/ ********************/
std::shared_ptr<SingleRange<size_t,SpaceType::NUL>>
SingleRangeFactory<size_t,SpaceType::NUL>::mRInstance = nullptr;
std::shared_ptr<NullRange> nullr() std::shared_ptr<NullRange> nullr()
{ {
return SingleRangeFactory<size_t,SpaceType::NUL>::mRInstance; static NullRF nrf; // just that mRInstance is initialized
static auto nr = std::dynamic_pointer_cast<NullRange>( nrf.create() );
VCHECK(NullRF::mRInstance);
return NullRF::mRInstance;
} }
std::shared_ptr<NullIndex> nulli() std::shared_ptr<NullIndex> nulli()
{ {
return std::make_shared<NullIndex>(nullr()); return std::make_shared<NullIndex>(nullr());
} }
std::shared_ptr<SingleRange<size_t,SpaceType::NUL>>
SingleRangeFactory<size_t,SpaceType::NUL>::mRInstance = nullptr;
SingleRangeFactory<size_t,SpaceType::NUL>::SingleRangeFactory() SingleRangeFactory<size_t,SpaceType::NUL>::SingleRangeFactory()
{ {
// Singleton // Singleton
if( not mRInstance){ if(not mRInstance){
if(not mProd){ if(not mProd){
mProd = std::shared_ptr<oType>( new SingleRange<size_t,SpaceType::NUL>() ); mProd = std::shared_ptr<oType>( new SingleRange<size_t,SpaceType::NUL>() );
setSelf(); setSelf();
} }
mRInstance = std::dynamic_pointer_cast<NullRange>( mProd );
} else { } else {
mProd = mRInstance; mProd = mRInstance;
} }