home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.10.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
include
IMP
version 2.10.0
swap_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/swap_macros.h
3
* \brief Various general useful macros for IMP.
4
*
5
* Copyright 2007-2018 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPKERNEL_SWAP_MACROS_H
10
#define IMPKERNEL_SWAP_MACROS_H
11
#include <IMP/kernel_config.h>
12
13
#if !defined(SWIG)
14
/** \name Swap helpers
15
16
Use the swap_with member function to swap two objects. The two
17
objects must be of the same type (Name) and define
18
the method \c swap_with(). The number suffix is the number of template
19
arguments, all of which must be of class type.
20
@{
21
*/
22
#define IMP_SWAP(Name) \
23
inline void swap(Name& a, Name& b) { a.swap_with(b); } \
24
IMP_REQUIRE_SEMICOLON_NAMESPACE
25
26
#define IMP_SWAP_1(Name) \
27
template <class A> \
28
inline void swap(Name<A>& a, Name<A>& b) { \
29
a.swap_with(b); \
30
} \
31
IMP_REQUIRE_SEMICOLON_NAMESPACE
32
33
#define IMP_SWAP_2(Name) \
34
template <class A, class B> \
35
inline void swap(Name<A, B>& a, Name<A, B>& b) { \
36
a.swap_with(b); \
37
} \
38
IMP_REQUIRE_SEMICOLON_NAMESPACE
39
40
#define IMP_SWAP_3(Name) \
41
template <class A, class B, class C> \
42
inline void swap(Name<A, B, C>& a, Name<A, B, C>& b) { \
43
a.swap_with(b); \
44
} \
45
IMP_REQUIRE_SEMICOLON_NAMESPACE
46
47
/** @} */
48
#else
49
#define IMP_SWAP(Name)
50
51
#define IMP_SWAP_1(Name)
52
53
#define IMP_SWAP_2(Name)
54
55
#define IMP_SWAP_3(Name)
56
#endif
57
58
//! Swap two member variables assuming the other object is called o
59
/** Swap the member \c var_name of the two objects (this and o).
60
*/
61
#define IMP_SWAP_MEMBER(var_name) swap(var_name, o.var_name)
62
63
#endif
/* IMPKERNEL_SWAP_MACROS_H */