Browse Source

move operations are 'noexcept'. implement copy_out() for stringpair and message.

master
roker 4 months ago
parent
commit
f1179d91da
2 changed files with 13 additions and 2 deletions
  1. +11
    -0
      src/types.cc
  2. +2
    -2
      src/wrapper.hh

+ 11
- 0
src/types.cc View File

@ -48,6 +48,12 @@ namespace pEp
free_message(m);
}
template<>
::message* Wrapper<::message*>::copy_out() const
{
return ::message_dup(value);
}
////////////////
template<>
@ -85,6 +91,11 @@ namespace pEp
free_stringpair(sp);
}
template<>
::stringpair_t* Wrapper<::stringpair_t*>::copy_out() const
{
return ::stringpair_dup(value);
}
template<>
void Wrapper<::stringpair_list_t*>::_free(::stringpair_list_t* spl)


+ 2
- 2
src/wrapper.hh View File

@ -63,13 +63,13 @@ public:
Wrapper(Args... args) : value{ this->_new(args...) } {}
// move is easy, efficient and generic:
Wrapper(Wrapper<T*>&& victim)
Wrapper(Wrapper<T*>&& victim) noexcept
: value{ victim.value}
{
victim.value = nullptr;
}
Wrapper<T*>& operator=(Wrapper<T*>&& victim)
Wrapper<T*>& operator=(Wrapper<T*>&& victim) noexcept
{
_free(value);
value = victim.value;


Loading…
Cancel
Save