nlib
Swap.h
1
2
/*--------------------------------------------------------------------------------*
3
Project: CrossRoad
4
Copyright (C)Nintendo All rights reserved.
5
6
These coded instructions, statements, and computer programs contain proprietary
7
information of Nintendo and/or its licensed developers and are protected by
8
national and international copyright laws. They may not be disclosed to third
9
parties or copied or duplicated in any form, in whole or in part, without the
10
prior written consent of Nintendo.
11
12
The content herein is highly confidential and should be handled accordingly.
13
*--------------------------------------------------------------------------------*/
14
15
#pragma once
16
#ifndef INCLUDE_NN_NLIB_SWAP_H_
17
#define INCLUDE_NN_NLIB_SWAP_H_
18
19
#include "
nn/nlib/Config.h
"
20
#ifdef NLIB_CXX11_SWAPHEADER
21
# include <utility>
// NOLINT
22
#else
23
# include <algorithm>
// NOLINT
24
#endif
25
26
#if defined(NLIB_CXX11_NOEXCEPT) && defined(NLIB_HAS_NATIVE_TYPETRAITS)
27
# include <type_traits>
// NOLINT
28
#define NLIB_DEFINE_STD_SWAP(tp) \
29
namespace std { template<> inline void swap<tp> (tp& lhs, tp& rhs) noexcept(
/* NOLINT */
\
30
std::is_nothrow_move_constructible<tp>::value && \
31
std::is_nothrow_move_assignable<tp>::value) { lhs.swap(rhs); } }
32
#else
33
#define NLIB_DEFINE_STD_SWAP(tp) \
34
namespace std { template<> inline void swap<tp> \
35
(tp& lhs, tp& rhs) { lhs.swap(rhs); } } // NOLINT
36
#endif
37
38
#ifndef NLIB_STD_SWAP_WORKAROUND
39
# define NLIB_DEFINE_STD_SWAP_T_BEGIN1(ns1) namespace ns1 { // NOLINT
40
# define NLIB_DEFINE_STD_SWAP_T_BEGIN2(ns1, ns2) namespace ns1 { namespace ns2 { // NOLINT
41
# define NLIB_DEFINE_STD_SWAP_T_BEGIN3(ns1, ns2, ns3) \
42
namespace ns1 { namespace ns2 { namespace ns3 { // NOLINT
43
# define NLIB_DEFINE_STD_SWAP_T_BEGIN4(ns1, ns2, ns3, ns4) \
44
namespace ns1 { namespace ns2 { namespace ns3 { namespace ns4 { // NOLINT
45
# define NLIB_DEFINE_STD_SWAP_T_END1(ns1) } // NOLINT
46
# define NLIB_DEFINE_STD_SWAP_T_END2(ns1, ns2) }} // NOLINT
47
# define NLIB_DEFINE_STD_SWAP_T_END3(ns1, ns2, ns3) }}} // NOLINT
48
# define NLIB_DEFINE_STD_SWAP_T_END4(ns1, ns2, ns3, ns4) }}}} // NOLINT
49
# define NLIB_DEFINE_STD_SWAP_T1(targ1, tp) \
50
template<class targ1> NLIB_ALWAYS_INLINE void swap \
51
(tp<targ1>& lhs, tp<targ1>& rhs) { lhs.swap(rhs); } // NOLINT
52
# define NLIB_DEFINE_STD_SWAP_T2(targ1, targ2, tp) \
53
template<class targ1, class targ2> NLIB_ALWAYS_INLINE void swap \
54
(tp<targ1, targ2>& lhs, tp<targ1, targ2>& rhs) { lhs.swap(rhs); } // NOLINT
55
#else
56
// This code is for the compilers which std::swap has priority over ADL.
57
# define NLIB_DEFINE_STD_SWAP_T_BEGIN1(ns1) namespace std { // NOLINT
58
# define NLIB_DEFINE_STD_SWAP_T_BEGIN2(ns1, ns2) namespace std { // NOLINT
59
# define NLIB_DEFINE_STD_SWAP_T_BEGIN3(ns1, ns2, ns3) namespace std { // NOLINT
60
# define NLIB_DEFINE_STD_SWAP_T_BEGIN4(ns1, ns2, ns3, ns4) namespace std { // NOLINT
61
# define NLIB_DEFINE_STD_SWAP_T_END1(ns1) } // NOLINT
62
# define NLIB_DEFINE_STD_SWAP_T_END2(ns1, ns2) } // NOLINT
63
# define NLIB_DEFINE_STD_SWAP_T_END3(ns1, ns2, ns3) } // NOLINT
64
# define NLIB_DEFINE_STD_SWAP_T_END4(ns1, ns2, ns3, ns4) } // NOLINT
65
# define NLIB_DEFINE_STD_SWAP_T1(targ1, tp) \
66
template<class targ1> NLIB_ALWAYS_INLINE void \
67
swap(tp<targ1>& lhs, tp<targ1>& rhs) { lhs.swap(rhs); } // NOLINT
68
# define NLIB_DEFINE_STD_SWAP_T2(targ1, targ2, tp) \
69
template<class targ1, class targ2> NLIB_ALWAYS_INLINE void \
70
swap(tp<targ1, targ2>& lhs, tp<targ1, targ2>& rhs) { lhs.swap(rhs); } // NOLINT
71
#endif
72
73
#endif // INCLUDE_NN_NLIB_SWAP_H_
Config.h
開発環境別の設定が書かれるファイルです。
© 2012-2017 Nintendo Co., Ltd. All rights reserved.