Skip to content

Commit 9a4551b

Browse files
sukeyacary-ilm
authored andcommitted
Fix calling default constructor by uniform init. (#340)
I fixed calling default constructor in ImathTypeTraits.h by using uniform initialization. Signed-off-by: Yuya Asano <[email protected]>
1 parent e6eb5f9 commit 9a4551b

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

src/Imath/ImathTypeTraits.h

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ struct has_xy {
8686
typedef char No[2];
8787

8888
// Valid only if .x, .y exist and are the right type: return a Yes.
89-
template<typename C,
90-
IMATH_ENABLE_IF(std::is_same<decltype(C().x), Base>::value),
91-
IMATH_ENABLE_IF(std::is_same<decltype(C().y), Base>::value)>
92-
static Yes& test(int);
89+
template <
90+
typename C,
91+
IMATH_ENABLE_IF (std::is_same<decltype (C {}.x), Base>::value),
92+
IMATH_ENABLE_IF (std::is_same<decltype (C {}.y), Base>::value)>
93+
static Yes& test (int);
9394

9495
// Fallback, default to returning a No.
9596
template<typename C> static No& test(...);
@@ -110,11 +111,12 @@ struct has_xyz {
110111
typedef char No[2];
111112

112113
// Valid only if .x, .y, .z exist and are the right type: return a Yes.
113-
template<typename C,
114-
IMATH_ENABLE_IF(std::is_same<decltype(C().x), Base>::value),
115-
IMATH_ENABLE_IF(std::is_same<decltype(C().y), Base>::value),
116-
IMATH_ENABLE_IF(std::is_same<decltype(C().z), Base>::value)>
117-
static Yes& test(int);
114+
template <
115+
typename C,
116+
IMATH_ENABLE_IF (std::is_same<decltype (C {}.x), Base>::value),
117+
IMATH_ENABLE_IF (std::is_same<decltype (C {}.y), Base>::value),
118+
IMATH_ENABLE_IF (std::is_same<decltype (C {}.z), Base>::value)>
119+
static Yes& test (int);
118120

119121
// Fallback, default to returning a No.
120122
template<typename C> static No& test(...);
@@ -135,12 +137,13 @@ struct has_xyzw {
135137
typedef char No[2];
136138

137139
// Valid only if .x, .y, .z, .w exist and are the right type: return a Yes.
138-
template<typename C,
139-
IMATH_ENABLE_IF(std::is_same<decltype(C().x), Base>::value),
140-
IMATH_ENABLE_IF(std::is_same<decltype(C().y), Base>::value),
141-
IMATH_ENABLE_IF(std::is_same<decltype(C().z), Base>::value),
142-
IMATH_ENABLE_IF(std::is_same<decltype(C().w), Base>::value)>
143-
static Yes& test(int);
140+
template <
141+
typename C,
142+
IMATH_ENABLE_IF (std::is_same<decltype (C {}.x), Base>::value),
143+
IMATH_ENABLE_IF (std::is_same<decltype (C {}.y), Base>::value),
144+
IMATH_ENABLE_IF (std::is_same<decltype (C {}.z), Base>::value),
145+
IMATH_ENABLE_IF (std::is_same<decltype (C {}.w), Base>::value)>
146+
static Yes& test (int);
144147

145148
// Fallback, default to returning a No.
146149
template<typename C> static No& test(...);
@@ -162,9 +165,12 @@ struct has_subscript {
162165
typedef char No[2];
163166

164167
// Valid only if T[] is possible and is the right type: return a Yes.
165-
template<typename C,
166-
IMATH_ENABLE_IF(std::is_same<typename std::decay<decltype(C()[0])>::type, Base>::value)>
167-
static Yes& test(int);
168+
template <
169+
typename C,
170+
IMATH_ENABLE_IF (std::is_same<
171+
typename std::decay<decltype (C {}[0])>::type,
172+
Base>::value)>
173+
static Yes& test (int);
168174

169175
// Fallback, default to returning a No.
170176
template<typename C> static No& test(...);
@@ -191,9 +197,12 @@ struct has_double_subscript {
191197
typedef char No[2];
192198

193199
// Valid only if T[][] is possible and is the right type: return a Yes.
194-
template<typename C,
195-
IMATH_ENABLE_IF(std::is_same<typename std::decay<decltype(C()[0][0])>::type, Base>::value)>
196-
static Yes& test(int);
200+
template <
201+
typename C,
202+
IMATH_ENABLE_IF (std::is_same<
203+
typename std::decay<decltype (C {}[0][0])>::type,
204+
Base>::value)>
205+
static Yes& test (int);
197206

198207
// Fallback, default to returning a No.
199208
template<typename C> static No& test(...);

0 commit comments

Comments
 (0)