Page MenuHomePhabricator

Move Constructors / Move Assignment for C++ Wrappers Session and Channel
Open, WishlistPublic

Description

Move Constructor of Channel and Session would allow to store them in standard containers. The implementation is trivial, but they should only be activated in C++ >= 11.

Sketch/Example for possible implementation:

Session::Session(Session && other) noexcept : 
  c_session()
{
  ::std::swap(c_session, other.c_session);
}

Session::~Session() noexcept
{
  if (c_session)
  {   
     ::ssh_free(c_session);
     c_session = nullptr;
  }
}

Channel::Channel(Channel && other) noexcept : session(), channel()
{
  using ::std::swap;
  swap(session, other.session);
  swap(channel, other.channel);
}

Channel::~Channel() noexcept 
{
  if (channel)
  {
     ::ssh_channel_free(channel);
     channel=nullptr;
  }
}

Event Timeline

cocus triaged this task as Wishlist priority.Dec 10 2019, 5:20 PM
cocus created this task.