Возвращение экземпляров синглтонов по ссылке

This commit is contained in:
2020-04-09 09:45:20 +03:00
parent 7ec97f8f19
commit e160b83c45
4 changed files with 15 additions and 15 deletions

View File

@ -85,10 +85,10 @@ public:
* @brief getInstance
* @return Уникальный экземпляр класса Paths
*/
static Paths* instance()
static Paths& instance()
{
static Paths p;
return( &p );
return( p );
}

View File

@ -13,7 +13,7 @@ namespace filesystem {
PathsMT::PathsMT() = default;
PathsMT* PathsMT::instance()
PathsMT& PathsMT::instance()
{
volatile PathsMT* localInstance = mInstance.load( std::memory_order_acquire );
if ( localInstance == nullptr )
@ -26,7 +26,7 @@ PathsMT* PathsMT::instance()
mInstance.store( const_cast< PathsMT* >( localInstance ), std::memory_order_release ); // NOLINT
}
}
return( const_cast< PathsMT* >( localInstance ) ); // NOLINT
return( const_cast< PathsMT& >( *localInstance ) ); // NOLINT
}
} // namespace filesystem

View File

@ -40,7 +40,7 @@ public:
* @brief getInstance
* @return Уникальный экземпляр класса PathsMT
*/
static PathsMT* instance();
static PathsMT& instance();
}; // class PathsMT
} // namespace filesystem