1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Created c++11 move constructors and operator= methods for a bunch of classes (only enabled for c++11 compilers, of course)

This commit is contained in:
Julian Storer 2011-08-21 21:20:28 +01:00
parent 2c328dfedc
commit ffc2f5d40e
46 changed files with 629 additions and 39 deletions

View file

@ -1169,7 +1169,7 @@ PopupMenu::PopupMenu()
PopupMenu::PopupMenu (const PopupMenu& other)
: lookAndFeel (other.lookAndFeel),
separatorPending (false)
separatorPending (other.separatorPending)
{
items.addCopiesOf (other.items);
}
@ -1187,6 +1187,28 @@ PopupMenu& PopupMenu::operator= (const PopupMenu& other)
return *this;
}
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
PopupMenu::PopupMenu (PopupMenu&& other) noexcept
: lookAndFeel (other.lookAndFeel),
separatorPending (other.separatorPending)
{
items.swapWithArray (other.items);
}
PopupMenu& PopupMenu::operator= (PopupMenu&& other) noexcept
{
if (this != &other)
{
items.swapWithArray (other.items);
lookAndFeel = other.lookAndFeel;
separatorPending = other.separatorPending;
}
return *this;
}
#endif
PopupMenu::~PopupMenu()
{
clear();

View file

@ -91,6 +91,11 @@ public:
/** Copies this menu from another one. */
PopupMenu& operator= (const PopupMenu& other);
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
PopupMenu (PopupMenu&& other) noexcept;
PopupMenu& operator= (PopupMenu&& other) noexcept;
#endif
//==============================================================================
/** Resets the menu, removing all its items. */
void clear();

View file

@ -148,6 +148,20 @@ MouseCursor& MouseCursor::operator= (const MouseCursor& other)
return *this;
}
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
MouseCursor::MouseCursor (MouseCursor&& other) noexcept
: cursorHandle (other.cursorHandle)
{
other.cursorHandle = nullptr;
}
MouseCursor& MouseCursor::operator= (MouseCursor&& other) noexcept
{
std::swap (cursorHandle, other.cursorHandle);
return *this;
}
#endif
bool MouseCursor::operator== (const MouseCursor& other) const noexcept
{
return getHandle() == other.getHandle();

View file

@ -99,6 +99,11 @@ public:
/** Destructor. */
~MouseCursor();
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
MouseCursor (MouseCursor&& other) noexcept;
MouseCursor& operator= (MouseCursor&& other) noexcept;
#endif
/** Checks whether two mouse cursors are the same.
For custom cursors, two cursors created from the same image won't be