mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: change refCount (internal) from count() to use_count()
- allows unambiguous of count() for other classes. Naming as per std::shared_ptr. STYLE: qualify use_count() and unique() methods with the refCount base - clearer/consistent meaning
This commit is contained in:
@ -41,7 +41,7 @@ void printInfo(const tmp<T>& item, const bool verbose = false)
|
||||
<< " movable:" << Switch(item.movable());
|
||||
if (item)
|
||||
{
|
||||
Info<< " refCount:" << item->count();
|
||||
Info<< " refCount:" << item->use_count();
|
||||
}
|
||||
|
||||
Info<< " move-constructible:"
|
||||
|
||||
@ -276,7 +276,7 @@ inline void Foam::token::reset()
|
||||
|
||||
case tokenType::COMPOUND:
|
||||
{
|
||||
if (data_.compoundPtr->unique())
|
||||
if (data_.compoundPtr->refCount::unique())
|
||||
{
|
||||
delete data_.compoundPtr;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -72,7 +72,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return the current reference count
|
||||
int count() const noexcept
|
||||
int use_count() const noexcept
|
||||
{
|
||||
return count_;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,9 +34,9 @@ License
|
||||
template<class T>
|
||||
inline void Foam::tmp<T>::incrCount()
|
||||
{
|
||||
ptr_->operator++();
|
||||
ptr_->refCount::operator++();
|
||||
|
||||
if (ptr_->count() > 1)
|
||||
if (ptr_->refCount::use_count() > 1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempt to create more than 2 tmp's referring to the same"
|
||||
@ -79,7 +79,7 @@ inline Foam::tmp<T>::tmp(T* p)
|
||||
ptr_(p),
|
||||
type_(PTR)
|
||||
{
|
||||
if (ptr_ && !ptr_->unique())
|
||||
if (ptr_ && !ptr_->refCount::unique())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted construction of a "
|
||||
@ -195,7 +195,7 @@ inline Foam::tmp<T>::~tmp() noexcept
|
||||
template<class T>
|
||||
inline bool Foam::tmp<T>::movable() const noexcept
|
||||
{
|
||||
return (is_pointer() && ptr_ && ptr_->unique());
|
||||
return (is_pointer() && ptr_ && ptr_->refCount::unique());
|
||||
}
|
||||
|
||||
|
||||
@ -246,7 +246,7 @@ inline T* Foam::tmp<T>::ptr() const
|
||||
|
||||
if (is_pointer())
|
||||
{
|
||||
if (!ptr_->unique())
|
||||
if (!ptr_->refCount::unique())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempt to acquire pointer to object referred to"
|
||||
@ -271,13 +271,13 @@ inline void Foam::tmp<T>::clear() const noexcept
|
||||
{
|
||||
if (is_pointer() && ptr_)
|
||||
{
|
||||
if (ptr_->unique())
|
||||
if (ptr_->refCount::unique())
|
||||
{
|
||||
delete ptr_;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_->operator--();
|
||||
ptr_->refCount::operator--();
|
||||
}
|
||||
ptr_ = nullptr;
|
||||
}
|
||||
@ -479,7 +479,7 @@ inline void Foam::tmp<T>::operator=(T* p)
|
||||
<< this->typeName()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
else if (!p->unique())
|
||||
else if (!p->refCount::unique())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted assignment of a "
|
||||
|
||||
Reference in New Issue
Block a user