Core/Signal: Implement copy constructor/copy assignation operator

This commit is contained in:
Lynix 2019-03-17 18:06:05 +01:00
parent 439a62a7f8
commit bdb5a4b3bd
3 changed files with 26 additions and 4 deletions

View File

@ -171,6 +171,7 @@ Nazara Engine:
- Fixed missing static Vector4::DotProduct implementation - Fixed missing static Vector4::DotProduct implementation
- ⚠ **By default, Nazara computes the mass center of all 2D physics object when calling SetGeom** - ⚠ **By default, Nazara computes the mass center of all 2D physics object when calling SetGeom**
- ⚠ Added Collider2D::ComputeCenterOfMass - ⚠ Added Collider2D::ComputeCenterOfMass
- Signal now implement a copy constructor and copy assignation operator for convenience
Nazara Development Kit: Nazara Development Kit:
- Added ImageWidget (#139) - Added ImageWidget (#139)

View File

@ -32,7 +32,7 @@ namespace Nz
class ConnectionGuard; class ConnectionGuard;
Signal(); Signal();
Signal(const Signal&) = delete; Signal(const Signal&);
Signal(Signal&& signal) noexcept; Signal(Signal&& signal) noexcept;
~Signal() = default; ~Signal() = default;
@ -47,7 +47,7 @@ namespace Nz
void operator()(Args... args) const; void operator()(Args... args) const;
Signal& operator=(const Signal&) = delete; Signal& operator=(const Signal&);
Signal& operator=(Signal&& signal) noexcept; Signal& operator=(Signal&& signal) noexcept;
private: private:

View File

@ -18,13 +18,23 @@ namespace Nz
/*! /*!
* \brief Constructs a Signal object by default * \brief Constructs a Signal object by default
*/ */
template<typename... Args> template<typename... Args>
Signal<Args...>::Signal() : Signal<Args...>::Signal() :
m_slotIterator(0) m_slotIterator(0)
{ {
} }
/*!
* \brief Constructs a Signal object by default
*
* \remark It doesn't make sense to copy a signal, this is only available for convenience to allow compiler-generated copy constructors
*/
template<typename ...Args>
Signal<Args...>::Signal(const Signal&) :
Signal()
{
}
/*! /*!
* \brief Constructs a Signal object by move semantic * \brief Constructs a Signal object by move semantic
* *
@ -174,13 +184,24 @@ namespace Nz
m_slots[m_slotIterator]->callback(args...); m_slots[m_slotIterator]->callback(args...);
} }
/*!
* \brief Doesn't do anything
* \return A reference to this
*
* \remark This is only for convenience to allow compiled-generated assignation operator
*/
template<typename... Args>
Signal<Args...>& Signal<Args...>::operator=(const Signal&)
{
return *this;
}
/*! /*!
* \brief Moves the signal into this * \brief Moves the signal into this
* \return A reference to this * \return A reference to this
* *
* \param signal Signal to move in this * \param signal Signal to move in this
*/ */
template<typename... Args> template<typename... Args>
Signal<Args...>& Signal<Args...>::operator=(Signal&& signal) noexcept Signal<Args...>& Signal<Args...>::operator=(Signal&& signal) noexcept
{ {