libkazv
copy-helper.hpp File Reference
#include "libkazv-config.hpp"
Include dependency graph for copy-helper.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KAZV_DECLARE_COPYABLE(typeName)
 
#define KAZV_DEFINE_COPYABLE_UNIQUE_PTR(typeName, privateName)
 

Macro Definition Documentation

◆ KAZV_DECLARE_COPYABLE

#define KAZV_DECLARE_COPYABLE (   typeName)
Value:
typeName(const typeName &that); \
typeName(typeName &&that); \
typeName &operator=(const typeName &that); \
typeName &operator=(typeName &&that);

◆ KAZV_DEFINE_COPYABLE_UNIQUE_PTR

#define KAZV_DEFINE_COPYABLE_UNIQUE_PTR (   typeName,
  privateName 
)
Value:
typeName::typeName(const typeName &that) \
: privateName(std::make_unique<decltype(privateName)::element_type>(*(that.privateName))) \
{ \
} \
typeName::typeName(typeName &&that) \
: privateName(std::move(that.privateName)) \
{ \
} \
typeName &typeName::operator=(const typeName &that) \
{ \
if (privateName != that.privateName) { \
privateName.reset(); \
privateName = std::make_unique<decltype(privateName)::element_type>(*(that.privateName)); \
} \
return *this; \
} \
typeName &typeName::operator=(typeName &&that) \
{ \
if (privateName != that.privateName) { \
privateName.reset(); \
privateName = std::move(that.privateName); \
} \
return *this; \
}