From 15f4f38e48470f5f0b1ba7f42a725e8d9af869f4 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Sun, 29 Jul 2018 14:35:53 +0200 Subject: [PATCH] fix null range instace issue --- src/lib/ranges/range_types/null_range.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/ranges/range_types/null_range.cc b/src/lib/ranges/range_types/null_range.cc index 5398e8f..f19251b 100644 --- a/src/lib/ranges/range_types/null_range.cc +++ b/src/lib/ranges/range_types/null_range.cc @@ -13,27 +13,31 @@ namespace MultiArrayTools * SingleRange * ********************/ + std::shared_ptr> + SingleRangeFactory::mRInstance = nullptr; + std::shared_ptr nullr() { - return SingleRangeFactory::mRInstance; + static NullRF nrf; // just that mRInstance is initialized + static auto nr = std::dynamic_pointer_cast( nrf.create() ); + VCHECK(NullRF::mRInstance); + return NullRF::mRInstance; } std::shared_ptr nulli() { return std::make_shared(nullr()); } - - std::shared_ptr> - SingleRangeFactory::mRInstance = nullptr; SingleRangeFactory::SingleRangeFactory() { // Singleton - if( not mRInstance){ + if(not mRInstance){ if(not mProd){ mProd = std::shared_ptr( new SingleRange() ); setSelf(); } + mRInstance = std::dynamic_pointer_cast( mProd ); } else { mProd = mRInstance; }