@@ -20,38 +20,64 @@ struct CanBeCalled : std::false_type {};
20
20
template <typename T>
21
21
struct CanBeCalled <T, typename std::enable_if<std::is_same<typename T::result_type, Value>::value>::type> : std::true_type {};
22
22
23
- template <typename T>
23
+ template <typename T, typename Tag = void >
24
24
struct ArgPromoter
25
25
{
26
- ArgPromoter (const T* val) : m_ptr(val) {}
26
+ ArgPromoter (const T* val)
27
+ : m_ptr(val)
28
+ {
29
+ }
27
30
28
31
operator T () const { return *m_ptr; }
29
32
30
33
const T* m_ptr;
31
34
};
32
35
33
36
template <>
34
- struct ArgPromoter <EmptyValue>
37
+ struct ArgPromoter <EmptyValue, void >
35
38
{
36
39
public:
37
40
ArgPromoter (const EmptyValue*) {}
38
41
39
42
template <typename T>
40
- operator T () { return T (); }
43
+ operator T ()
44
+ {
45
+ return T ();
46
+ }
47
+ };
48
+
49
+ template <typename T>
50
+ struct ArgPromoter <T, std::enable_if_t <std::is_fundamental<T>::value>>
51
+ {
52
+ ArgPromoter (const T* val)
53
+ : m_ptr(val)
54
+ {
55
+ }
56
+
57
+ template <typename U = T, typename = std::enable_if_t <std::is_convertible<T, U>::value>>
58
+ operator U () const
59
+ {
60
+ return static_cast <U>(*m_ptr);
61
+ }
62
+
63
+ const T* m_ptr;
41
64
};
42
65
43
66
template <typename CharT>
44
- struct ArgPromoter <std::basic_string<CharT>>
67
+ struct ArgPromoter <std::basic_string<CharT>, void >
45
68
{
46
69
using string = std::basic_string<CharT>;
47
70
using string_view = nonstd::basic_string_view<CharT>;
48
71
using other_string = std::conditional_t <std::is_same<CharT, char >::value, std::wstring, std::string>;
49
72
using other_string_view = std::conditional_t <std::is_same<CharT, char >::value, nonstd::wstring_view, nonstd::string_view>;
50
73
51
- ArgPromoter (const string* str) : m_ptr(str) {}
74
+ ArgPromoter (const string* str)
75
+ : m_ptr(str)
76
+ {
77
+ }
52
78
53
79
operator const string&() const { return *m_ptr; }
54
- operator string () const { return *m_ptr; }
80
+ operator string () const { return *m_ptr; }
55
81
operator string_view () const { return *m_ptr; }
56
82
operator other_string () const
57
83
{
@@ -68,17 +94,20 @@ struct ArgPromoter<std::basic_string<CharT>>
68
94
};
69
95
70
96
template <typename CharT>
71
- struct ArgPromoter <nonstd::basic_string_view<CharT>>
97
+ struct ArgPromoter <nonstd::basic_string_view<CharT>, void >
72
98
{
73
99
using string = std::basic_string<CharT>;
74
100
using string_view = nonstd::basic_string_view<CharT>;
75
101
using other_string = std::conditional_t <std::is_same<CharT, char >::value, std::wstring, std::string>;
76
102
using other_string_view = std::conditional_t <std::is_same<CharT, char >::value, nonstd::wstring_view, nonstd::string_view>;
77
103
78
- ArgPromoter (const string_view* str) : m_ptr(str) {}
104
+ ArgPromoter (const string_view* str)
105
+ : m_ptr(str)
106
+ {
107
+ }
79
108
80
- operator const string_view& () const { return *m_ptr; }
81
- operator string_view () const { return *m_ptr; }
109
+ operator const string_view&() const { return *m_ptr; }
110
+ operator string_view () const { return *m_ptr; }
82
111
operator string () const { return string (m_ptr->begin (), m_ptr->end ()); }
83
112
operator other_string () const
84
113
{
@@ -132,7 +161,6 @@ struct UCInvoker
132
161
{
133
162
return Value ();
134
163
}
135
-
136
164
};
137
165
138
166
inline const Value& GetParamValue (const UserCallableParams& params, const ArgInfo& info)
0 commit comments