mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
New functions for creating cvf::refs to avoid "naked new" in App code
This commit is contained in:
@@ -137,8 +137,6 @@ template<typename T> inline void swap(ref<T>& a, ref<T>& b) { a.swap(b); }
|
|||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
//
|
//
|
||||||
// Smart pointer class for const pointers
|
// Smart pointer class for const pointers
|
||||||
@@ -181,6 +179,17 @@ template<typename T1, typename T2> inline bool operator!=(const cref<T1>& a, T2*
|
|||||||
template<typename T1, typename T2> inline bool operator==(T1* a, const cref<T2>& b) { return a == b.p(); } ///< Returns true if the naked pointer \a a is equal to the internal pointer of ref \a b.
|
template<typename T1, typename T2> inline bool operator==(T1* a, const cref<T2>& b) { return a == b.p(); } ///< Returns true if the naked pointer \a a is equal to the internal pointer of ref \a b.
|
||||||
template<typename T1, typename T2> inline bool operator!=(T1* a, const cref<T2>& b) { return a != b.p(); } ///< Returns true if the naked pointer \a a is different from the internal pointer of ref \a b.
|
template<typename T1, typename T2> inline bool operator!=(T1* a, const cref<T2>& b) { return a != b.p(); } ///< Returns true if the naked pointer \a a is different from the internal pointer of ref \a b.
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
//
|
||||||
|
// Creation of smart pointers.
|
||||||
|
//
|
||||||
|
//==================================================================================================
|
||||||
|
template<typename T, class... Args>
|
||||||
|
ref<T> make_ref(Args&&... args);
|
||||||
|
|
||||||
|
template<typename T, class... Args>
|
||||||
|
cref<T> make_cref(Args&&... args);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -566,5 +566,26 @@ void cref<T>::swap(cref& other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Creation of smart pointers.
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
template<typename T, class... Args>
|
||||||
|
ref<T> make_ref(Args&&... args)
|
||||||
|
{
|
||||||
|
return cvf::ref(new T(args...));
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Creation of const smart pointers.
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
template<typename T, class... Args>
|
||||||
|
cref<T> make_cref(Args&&... args)
|
||||||
|
{
|
||||||
|
return cvf::cref(new T(args...));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace cvf
|
} // namespace cvf
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user