1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/////////////////////////////////////////////////////////////////////////////
// Copyright (c) Electronic Arts Inc. All rights reserved.
/////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// The design for call_traits here is very similar to that found in template
// metaprogramming libraries such as Boost, GCC, and Metrowerks, given that
// these libraries have established this interface as a defacto standard for
// solving this problem. Also, these are described in various books on the
// topic of template metaprogramming, such as "Modern C++ Design".
//
// See http://www.boost.org/libs/utility/call_traits.htm or search for
// call_traits in Google for a description of call_traits.
///////////////////////////////////////////////////////////////////////////////
#ifndef EASTL_CALL_TRAITS_H
#define EASTL_CALL_TRAITS_H
#include <EASTL/internal/config.h>
#include <EASTL/type_traits.h>
#if defined(EA_PRAGMA_ONCE_SUPPORTED)
#pragma once // Some compilers (e.g. VC++) benefit significantly from using this. We've measured 3-4% build speed improvements in apps as a result.
#endif
namespace eastl
{
template <typename T, bool small_>
struct ct_imp2 { typedef const T& param_type; };
template <typename T>
struct ct_imp2<T, true> { typedef const T param_type; };
template <typename T, bool isp, bool b1>
struct ct_imp { typedef const T& param_type; };
template <typename T, bool isp>
struct ct_imp<T, isp, true> { typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type; };
template <typename T, bool b1>
struct ct_imp<T, true, b1> { typedef T const param_type; };
template <typename T>
struct call_traits
{
public:
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef typename ct_imp<T, is_pointer<T>::value, is_arithmetic<T>::value>::param_type param_type;
};
template <typename T>
struct call_traits<T&>
{
typedef T& value_type;
typedef T& reference;
typedef const T& const_reference;
typedef T& param_type;
};
template <typename T, size_t N>
struct call_traits<T [N]>
{
private:
typedef T array_type[N];
public:
typedef const T* value_type;
typedef array_type& reference;
typedef const array_type& const_reference;
typedef const T* const param_type;
};
template <typename T, size_t N>
struct call_traits<const T [N]>
{
private:
typedef const T array_type[N];
public:
typedef const T* value_type;
typedef array_type& reference;
typedef const array_type& const_reference;
typedef const T* const param_type;
};
} // namespace eastl
#endif // Header include guard
|