Noim

Added to class

Aug 13th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. ~LED() { delete [] pins, r, g, b, task, taskgoal; }
  2.     LED &operator=(LED const& other)
  3.     {
  4.         LED copy(other);
  5.         swap(*this, copy);
  6.         return *this;
  7.     }
  8.  
  9.     LED(LED&& that) noexcept
  10.         : pins(nullptr)
  11.         , r(0)
  12.         , g(0)
  13.         , b(0)
  14.         , task(0)
  15.         , taskgoal(0)
  16.     {
  17.         swap(*this, that);
  18.     }
  19.  
  20.     LED& operator=(LED&& that) noexcept
  21.     {
  22.         swap(*this, that);
  23.         return *this;
  24.     }
  25.  
  26.     friend void swap(LED& lhs, LED& rhs) noexcept
  27.     {
  28.         std::swap(lhs.pins, rhs.pins);
  29.         std::swap(lhs.r, rhs.r);
  30.         std::swap(lhs.g, rhs.g);
  31.         std::swap(lhs.b, rhs.b);
  32.         std::swap(lhs.task, rhs.task);
  33.         std::swap(lhs.taskgoal, rhs.taskgoal);
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment