mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0026549: Provide move constructors and operators for basic classes
Move constructor and operator added for opencascade::handle<>
This commit is contained in:
parent
4796758e8d
commit
5d351a0822
@ -69,6 +69,12 @@ namespace opencascade {
|
|||||||
BeginScope();
|
BeginScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Move constructor
|
||||||
|
handle (handle&& theHandle) : entity(theHandle.entity)
|
||||||
|
{
|
||||||
|
theHandle.entity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~handle ()
|
~handle ()
|
||||||
{
|
{
|
||||||
@ -104,6 +110,13 @@ namespace opencascade {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Move operator
|
||||||
|
handle& operator= (handle&& theHandle)
|
||||||
|
{
|
||||||
|
std::swap (this->entity, theHandle.entity);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//! STL-like cast to pointer to referred object
|
//! STL-like cast to pointer to referred object
|
||||||
const T* get () const { return static_cast<const T*>(this->entity); }
|
const T* get () const { return static_cast<const T*>(this->entity); }
|
||||||
|
|
||||||
@ -220,6 +233,14 @@ namespace opencascade {
|
|||||||
BeginScope();
|
BeginScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Generalized move constructor
|
||||||
|
template <class T2, typename = typename std::enable_if <is_base_but_not_same <T, T2>::value>::type>
|
||||||
|
handle (handle<T2>&& theHandle)
|
||||||
|
: entity(theHandle.entity)
|
||||||
|
{
|
||||||
|
theHandle.entity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//! Generalized assignment operator
|
//! Generalized assignment operator
|
||||||
template <class T2, typename = typename std::enable_if <is_base_but_not_same <T, T2>::value>::type>
|
template <class T2, typename = typename std::enable_if <is_base_but_not_same <T, T2>::value>::type>
|
||||||
handle operator = (const handle<T2>& theHandle)
|
handle operator = (const handle<T2>& theHandle)
|
||||||
@ -228,6 +249,14 @@ namespace opencascade {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Generalized move operator
|
||||||
|
template <class T2, typename = typename std::enable_if <is_base_but_not_same <T, T2>::value>::type>
|
||||||
|
handle& operator= (handle<T2>&& theHandle)
|
||||||
|
{
|
||||||
|
std::swap (this->entity, theHandle.entity);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
//! Upcast to const reference to base type.
|
//! Upcast to const reference to base type.
|
||||||
@ -260,6 +289,14 @@ namespace opencascade {
|
|||||||
BeginScope();
|
BeginScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Generalized move constructor
|
||||||
|
template <class T2>
|
||||||
|
handle (handle<T2>&& theHandle, typename std::enable_if <is_base_but_not_same <T, T2>::value>::type* = nullptr)
|
||||||
|
: entity(theHandle.entity)
|
||||||
|
{
|
||||||
|
theHandle.entity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//! Generalized assignment operator.
|
//! Generalized assignment operator.
|
||||||
template <class T2>
|
template <class T2>
|
||||||
handle operator = (const handle<T2>& theHandle)
|
handle operator = (const handle<T2>& theHandle)
|
||||||
@ -270,6 +307,16 @@ namespace opencascade {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Generalized move operator
|
||||||
|
template <class T2>
|
||||||
|
handle& operator= (handle<T2>&& theHandle)
|
||||||
|
{
|
||||||
|
std::enable_if <is_base_but_not_same <T, T2>::value, void*>::type aTypeCheckHelperVar;
|
||||||
|
(void)aTypeCheckHelperVar;
|
||||||
|
std::swap (this->entity, theHandle.entity);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
//! Upcast to const reference to base type.
|
//! Upcast to const reference to base type.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user