Skip to content

Commit

Permalink
Fix calling default constructor by uniform init. (AcademySoftwareFoun…
Browse files Browse the repository at this point in the history
…dation#340)

I fixed calling default constructor in ImathTypeTraits.h by using
uniform initialization.

Signed-off-by: Yuya Asano <[email protected]>
  • Loading branch information
sukeya authored and cary-ilm committed Jan 23, 2024
1 parent 237a81e commit 2254432
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions src/Imath/ImathTypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ struct has_xy {
typedef char No[2];

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

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

// Valid only if .x, .y, .z exist and are the right type: return a Yes.
template<typename C,
IMATH_ENABLE_IF(std::is_same<decltype(C().x), Base>::value),
IMATH_ENABLE_IF(std::is_same<decltype(C().y), Base>::value),
IMATH_ENABLE_IF(std::is_same<decltype(C().z), Base>::value)>
static Yes& test(int);
template <
typename C,
IMATH_ENABLE_IF (std::is_same<decltype (C {}.x), Base>::value),
IMATH_ENABLE_IF (std::is_same<decltype (C {}.y), Base>::value),
IMATH_ENABLE_IF (std::is_same<decltype (C {}.z), Base>::value)>
static Yes& test (int);

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

// Valid only if .x, .y, .z, .w exist and are the right type: return a Yes.
template<typename C,
IMATH_ENABLE_IF(std::is_same<decltype(C().x), Base>::value),
IMATH_ENABLE_IF(std::is_same<decltype(C().y), Base>::value),
IMATH_ENABLE_IF(std::is_same<decltype(C().z), Base>::value),
IMATH_ENABLE_IF(std::is_same<decltype(C().w), Base>::value)>
static Yes& test(int);
template <
typename C,
IMATH_ENABLE_IF (std::is_same<decltype (C {}.x), Base>::value),
IMATH_ENABLE_IF (std::is_same<decltype (C {}.y), Base>::value),
IMATH_ENABLE_IF (std::is_same<decltype (C {}.z), Base>::value),
IMATH_ENABLE_IF (std::is_same<decltype (C {}.w), Base>::value)>
static Yes& test (int);

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

// Valid only if T[] is possible and is the right type: return a Yes.
template<typename C,
IMATH_ENABLE_IF(std::is_same<typename std::decay<decltype(C()[0])>::type, Base>::value)>
static Yes& test(int);
template <
typename C,
IMATH_ENABLE_IF (std::is_same<
typename std::decay<decltype (C {}[0])>::type,
Base>::value)>
static Yes& test (int);

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

// Valid only if T[][] is possible and is the right type: return a Yes.
template<typename C,
IMATH_ENABLE_IF(std::is_same<typename std::decay<decltype(C()[0][0])>::type, Base>::value)>
static Yes& test(int);
template <
typename C,
IMATH_ENABLE_IF (std::is_same<
typename std::decay<decltype (C {}[0][0])>::type,
Base>::value)>
static Yes& test (int);

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

0 comments on commit 2254432

Please sign in to comment.