mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
tmp: Updated to store and preserve the const-ness of the reference to a constant object
This change requires that the de-reference operator '()' returns a const-reference to the object stored irrespective of the const-ness of object stored and the new member function 'ref()' is provided to return an non-const reference to stored object which throws a fatal error if the stored object is const. In order to smooth the transition to this new safer 'tmp' the now deprecated and unsafe non-const de-reference operator '()' is still provided by default but may be switched-off with the compilation switch 'CONST_TMP'. The main OpenFOAM library has already been upgraded and '-DCONST_TMP' option specified in the 'options' file to switch to the new 'tmp' behavior. The rest of OpenFOAM-dev will be upgraded over the following few weeks. Henry G. Weller CFD Direct
This commit is contained in:
@ -92,7 +92,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::value
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tfld(new Field<Type>(x.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
Field<Type>& fld = tfld.ref();
|
||||
|
||||
forAll(x, i)
|
||||
{
|
||||
@ -110,7 +110,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::integrate
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tfld(new Field<Type>(x1.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
Field<Type>& fld = tfld.ref();
|
||||
|
||||
forAll(x1, i)
|
||||
{
|
||||
|
||||
@ -380,7 +380,7 @@ template<class Type>
|
||||
Foam::tmp<Foam::scalarField> Foam::Function1Types::TableBase<Type>::x() const
|
||||
{
|
||||
tmp<scalarField> tfld(new scalarField(table_.size(), 0.0));
|
||||
scalarField& fld = tfld();
|
||||
scalarField& fld = tfld.ref();
|
||||
|
||||
forAll(table_, i)
|
||||
{
|
||||
@ -395,7 +395,7 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::TableBase<Type>::y() const
|
||||
{
|
||||
tmp<Field<Type>> tfld(new Field<Type>(table_.size(), pTraits<Type>::zero));
|
||||
Field<Type>& fld = tfld();
|
||||
Field<Type>& fld = tfld.ref();
|
||||
|
||||
forAll(table_, i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user