Browse Source

okay, we allow copying for all Wrapper where copy_out() is implemented.

master
roker 9 months ago
parent
commit
7973a9638b
2 changed files with 15 additions and 7 deletions
  1. +1
    -1
      src/identity.cc
  2. +14
    -6
      src/wrapper.hh

+ 1
- 1
src/identity.cc View File

@ -24,7 +24,7 @@ namespace pEp
}
template<>
::pEp_identity* Wrapper<::pEp_identity*>::copy_out()
::pEp_identity* Wrapper<::pEp_identity*>::copy_out() const
{
return identity_dup(value);
}


+ 14
- 6
src/wrapper.hh View File

@ -62,11 +62,7 @@ public:
template<class... Args>
Wrapper(Args... args) : value{ this->_new(args...) } {}
// no implicit copying... (yet?)
Wrapper(const Wrapper<T*>&) = delete;
void operator=(const Wrapper<T*>&) = delete;
// must be implemented separately for each T
// move is easy, efficient and generic:
Wrapper(Wrapper<T*>&& victim)
: value{ victim.value}
{
@ -80,6 +76,18 @@ public:
victim.value = nullptr;
return *this;
}
Wrapper(const Wrapper<T*>& orig)
: value{ orig.copy_out() }
{}
Wrapper<T*>& operator=(const Wrapper<T*>& orig)
{
if(&orig == this) return *this;
_free(value);
value = orig.copy_out();
return *this;
}
~Wrapper()
{
@ -107,7 +115,7 @@ public:
// only implemented for the datatypes where necessay.
// other implementations can follow if necessary.
T* copy_out();
T* copy_out() const;
protected:


Loading…
Cancel
Save