nlib
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
Swap.h
1
2
#pragma once
3
#ifndef INCLUDE_NN_NLIB_SWAP_H_
4
#define INCLUDE_NN_NLIB_SWAP_H_
5
6
#include "
nn/nlib/Config.h
"
7
#ifdef NLIB_CXX11_SWAPHEADER
8
# include <utility>
// NOLINT
9
#else
10
# include <algorithm>
// NOLINT
11
#endif
12
13
#if defined(NLIB_CXX11_NOEXCEPT) && defined(NLIB_HAS_NATIVE_TYPETRAITS)
14
# include <type_traits>
// NOLINT
15
#define NLIB_DEFINE_STD_SWAP(tp) \
16
namespace std { template<> inline void swap<tp> (tp& lhs, tp& rhs) noexcept(
/* NOLINT */
\
17
std::is_nothrow_move_constructible<tp>::value && \
18
std::is_nothrow_move_assignable<tp>::value) { lhs.swap(rhs); } }
19
#else
20
#define NLIB_DEFINE_STD_SWAP(tp) \
21
namespace std { template<> inline void swap<tp> \
22
(tp& lhs, tp& rhs) { lhs.swap(rhs); } } // NOLINT
23
#endif
24
25
#ifndef NLIB_STD_SWAP_WORKAROUND
26
# define NLIB_DEFINE_STD_SWAP_T_BEGIN1(ns1) namespace ns1 { // NOLINT
27
# define NLIB_DEFINE_STD_SWAP_T_BEGIN2(ns1, ns2) namespace ns1 { namespace ns2 { // NOLINT
28
# define NLIB_DEFINE_STD_SWAP_T_BEGIN3(ns1, ns2, ns3) \
29
namespace ns1 { namespace ns2 { namespace ns3 { // NOLINT
30
# define NLIB_DEFINE_STD_SWAP_T_BEGIN4(ns1, ns2, ns3, ns4) \
31
namespace ns1 { namespace ns2 { namespace ns3 { namespace ns4 { // NOLINT
32
# define NLIB_DEFINE_STD_SWAP_T_END1(ns1) } // NOLINT
33
# define NLIB_DEFINE_STD_SWAP_T_END2(ns1, ns2) }} // NOLINT
34
# define NLIB_DEFINE_STD_SWAP_T_END3(ns1, ns2, ns3) }}} // NOLINT
35
# define NLIB_DEFINE_STD_SWAP_T_END4(ns1, ns2, ns3, ns4) }}}} // NOLINT
36
# define NLIB_DEFINE_STD_SWAP_T1(targ1, tp) \
37
template<class targ1> NLIB_ALWAYS_INLINE void swap \
38
(tp<targ1>& lhs, tp<targ1>& rhs) { lhs.swap(rhs); } // NOLINT
39
# define NLIB_DEFINE_STD_SWAP_T2(targ1, targ2, tp) \
40
template<class targ1, class targ2> NLIB_ALWAYS_INLINE void swap \
41
(tp<targ1, targ2>& lhs, tp<targ1, targ2>& rhs) { lhs.swap(rhs); } // NOLINT
42
#else
43
// This code is for the compilers which std::swap has priority over ADL.
44
# define NLIB_DEFINE_STD_SWAP_T_BEGIN1(ns1) namespace std { // NOLINT
45
# define NLIB_DEFINE_STD_SWAP_T_BEGIN2(ns1, ns2) namespace std { // NOLINT
46
# define NLIB_DEFINE_STD_SWAP_T_BEGIN3(ns1, ns2, ns3) namespace std { // NOLINT
47
# define NLIB_DEFINE_STD_SWAP_T_BEGIN4(ns1, ns2, ns3, ns4) namespace std { // NOLINT
48
# define NLIB_DEFINE_STD_SWAP_T_END1(ns1) } // NOLINT
49
# define NLIB_DEFINE_STD_SWAP_T_END2(ns1, ns2) } // NOLINT
50
# define NLIB_DEFINE_STD_SWAP_T_END3(ns1, ns2, ns3) } // NOLINT
51
# define NLIB_DEFINE_STD_SWAP_T_END4(ns1, ns2, ns3, ns4) } // NOLINT
52
# define NLIB_DEFINE_STD_SWAP_T1(targ1, tp) \
53
template<class targ1> NLIB_ALWAYS_INLINE void \
54
swap(tp<targ1>& lhs, tp<targ1>& rhs) { lhs.swap(rhs); } // NOLINT
55
# define NLIB_DEFINE_STD_SWAP_T2(targ1, targ2, tp) \
56
template<class targ1, class targ2> NLIB_ALWAYS_INLINE void \
57
swap(tp<targ1, targ2>& lhs, tp<targ1, targ2>& rhs) { lhs.swap(rhs); } // NOLINT
58
#endif
59
60
#endif // INCLUDE_NN_NLIB_SWAP_H_
Config.h
A file that contains the configuration information for each development environment.
© 2013, 2014, 2015 Nintendo Co., Ltd. All rights reserved.