HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
UT_Swap.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: UT_Swap.h (UT Library, C++)
7
*
8
* COMMENTS:
9
*/
10
11
#ifndef __UT_SWAP_H_INCLUDED__
12
#define __UT_SWAP_H_INCLUDED__
13
14
#include <
SYS/SYS_Inline.h
>
15
#include <utility>
16
#include <stddef.h>
17
18
/// Generic swap so that it will always work for specializations that use
19
/// argument-dependent lookup (ADL).
20
///
21
/// Contrived specialization example:
22
/// (note that this is not necessary if MyClass obeys rule of zero)
23
/// @code
24
/// class MyClass
25
/// {
26
/// friend void swap(MyClass& a, Myclass &b)
27
/// {
28
/// UTswap(a.myFirstDataMember, b.myFirstDataMember);
29
/// UTswap(a.mySecondDataMember, b.mySecondDataMember);
30
/// }
31
/// };
32
/// @endcode
33
/// @{
34
template
<
typename
T>
35
void
UTswap
(T&
a
, T&
b
)
36
{
37
using namespace
std;
38
swap
(a, b);
39
}
40
template
<
typename
T,
size_t
N>
41
void
UTswap
(T (&
a
)[
N
], T (&
b
)[N])
42
{
43
using namespace
std;
44
swap
(
a
,
b
);
45
}
46
template
<
typename
T,
size_t
S>
47
inline
void
48
UTswap
(T (&
a
)[S], T (&
b
)[S],
size_t
at_most)
49
{
50
if
(at_most > S)
51
at_most = S;
52
for
(
size_t
i = 0; i < at_most; i++)
53
UTswap<T>(
a
[i],
b
[i]);
54
}
55
/// @}
56
57
/// Macro for specializing std::swap() and UTswap() for classes that have a
58
/// swap method.
59
/// @{
60
#define UT_SWAPPER_CLASS(T) \
61
SYS_FORCE_INLINE void UTswap(T &a, T &b) { a.swap(b); }
62
#define UT_SWAPPER_TEMPLATE(T) \
63
template< typename TA > \
64
SYS_FORCE_INLINE void UTswap(T<TA> &a, T<TA> &b) { a.swap(b); }
65
/// @}
66
67
#endif // __UT_SWAP_H_INCLUDED__
UTswap
void UTswap(T &a, T &b)
Definition:
UT_Swap.h:35
std::swap
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
Definition:
UT_ArraySet.h:1639
a
GLboolean GLboolean GLboolean GLboolean a
Definition:
glcorearb.h:1222
SYS_Inline.h
b
GLboolean GLboolean GLboolean b
Definition:
glcorearb.h:1222
GA_Names::N
GA_API const UT_StringHolder N
UT
UT_Swap.h
Generated on Thu Nov 21 2024 02:46:15 for HDK by
1.8.6