T204: Move Constructors / Move Assignment for C++ Wrappers Session and Channel
Description
Originally reported by cocus: https://bugs.libssh.org/T204
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; } }
Comments:
Jakuje commented on 2020-09-22 14:58:25 UTC:
We are not primarily C++ developers so the C++ wrapper is the minimal support we could provide. If you know how to do this in sensible way, submitting a pull request with the patch (ideally also with demonstration in examples) would be the simplest way how to get this in.
https://gitlab.com/libssh/libssh-mirror