maliput
maliput_copyable.h File Reference

Detailed Description

Provides careful macros to selectively enable or disable the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment. http://en.cppreference.com/w/cpp/language/member_functions#Special_member_functions When enabled via these macros, the = default implementation is provided. Code that needs custom copy or move functions should not use these macros.

This graph shows which files directly or indirectly include this file:

Macros

#define MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)
 MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment. More...
 
#define MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname)
 MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN defaults the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment. More...
 
#define MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN(Classname)
 MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN declares (but does not define) the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment. More...
 
#define MALIPUT_DEFINE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN_T(Classname)
 Helper for MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN. More...
 

Macro Definition Documentation

◆ MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN

#define MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN (   Classname)
Value:
Classname(const Classname&); \
Classname& operator=(const Classname&); \
Classname(Classname&&); \
Classname& operator=(Classname&&); \
/* Fails at compile-time if default-copy doesn't work. */ \
static void MALIPUT_COPYABLE_DEMAND_COPY_CAN_COMPILE() { \
(void)static_cast<Classname& (Classname::*)(const Classname&)>(&Classname::operator=); \
}

MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN declares (but does not define) the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.

This is useful when paired with MALIPUT_DEFINE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN_T to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57728 whereby the declaration and definition must be split. Once Maliput no longer supports GCC versions prior to 6.3, this macro could be removed. Invoke this macro in the public section of the class declaration, e.g.:

template <typename T>
class Foo {
public:
// ...
};

◆ MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN

#define MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN (   Classname)
Value:
Classname(const Classname&) = default; \
Classname& operator=(const Classname&) = default; \
Classname(Classname&&) = default; \
Classname& operator=(Classname&&) = default; \
/* Fails at compile-time if default-copy doesn't work. */ \
static void MALIPUT_COPYABLE_DEMAND_COPY_CAN_COMPILE() { \
(void)static_cast<Classname& (Classname::*)(const Classname&)>(&Classname::operator=); \
}

MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN defaults the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.

This macro should be used only when copy-construction and copy-assignment defaults are well-formed. Note that the defaulted move functions could conceivably still be ill-formed, in which case they will effectively not be declared or used – but because the copy constructor exists the type will still be MoveConstructible. Invoke this this macro in the public section of the class declaration, e.g.:

class Foo {
public:
// ...
};

◆ MALIPUT_DEFINE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN_T

#define MALIPUT_DEFINE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN_T (   Classname)
Value:
template <typename T> \
Classname<T>::Classname(const Classname<T>&) = default; \
template <typename T> \
Classname<T>& Classname<T>::operator=(const Classname<T>&) = default; \
template <typename T> \
Classname<T>::Classname(Classname<T>&&) = default; \
template <typename T> \
Classname<T>& Classname<T>::operator=(Classname<T>&&) = default;

Helper for MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN.

Provides defaulted definitions for the four special member functions of a templated class.

◆ MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN

#define MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN (   Classname)
Value:
Classname(const Classname&) = delete; \
void operator=(const Classname&) = delete; \
Classname(Classname&&) = delete; \
void operator=(Classname&&) = delete;

MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.

Invoke this this macro in the public section of the class declaration, e.g.:

class Foo {
public:
// ...
};
MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN
#define MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN(Classname)
MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN declares (but does not define) the special member functions ...
Definition: maliput_copyable.h:141
MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN
#define MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)
MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction,...
Definition: maliput_copyable.h:91
MALIPUT_DEFINE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN_T
#define MALIPUT_DEFINE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN_T(Classname)
Helper for MALIPUT_DECLARE_COPY_AND_MOVE_AND_ASSIGN.
Definition: maliput_copyable.h:154
MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN
#define MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname)
MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN defaults the special member functions for copy-construction,...
Definition: maliput_copyable.h:113