From 9fa66ad826924bce45fa56d853097541fea95e72 Mon Sep 17 00:00:00 2001 From: Tarun Karuturi Date: Mon, 4 Nov 2024 22:03:18 -0800 Subject: [PATCH] Make EValue template constructor MSVC friendly (#6631) Summary: The current EValue template constructor is not MSVC friendly, in order to make it MSVC friendly had to make some small changes such as: - Using a default template argument (typename = typename std::enable_if<...>::type). This means that the std::enable_if condition is evaluated when the template is instantiated. - Separating the SFINAE condition from the function signature. Reviewed By: dbort Differential Revision: D65402442 --- runtime/core/evalue.h | 13 +++++++------ runtime/core/exec_aten/exec_aten.h | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/runtime/core/evalue.h b/runtime/core/evalue.h index 8003a89cbf0..500c2bc4f0e 100644 --- a/runtime/core/evalue.h +++ b/runtime/core/evalue.h @@ -242,12 +242,13 @@ struct EValue { // Template constructor that allows construction from types that can be // dereferenced to produce a type that EValue can be implicitly constructed // from. - template - /*implicit*/ EValue( - T&& value, - typename std::enable_if(value)), - EValue>::value>::type* = 0) { + template < + typename T, + typename = typename std::enable_if(std::declval())), // declval to simulate + // forwarding + EValue>::value>::type> + /*implicit*/ EValue(T&& value) { ET_CHECK_MSG(value != nullptr, "Pointer is null."); // Note that this ctor does not initialize this->tag directly; it is set by // moving in the new value. diff --git a/runtime/core/exec_aten/exec_aten.h b/runtime/core/exec_aten/exec_aten.h index bfb47daa05d..708fb69d577 100644 --- a/runtime/core/exec_aten/exec_aten.h +++ b/runtime/core/exec_aten/exec_aten.h @@ -9,6 +9,7 @@ #pragma once #include // @manual +#include #ifdef USE_ATEN_LIB #include // @manual #include