Skip to content

Commit ff8914d

Browse files
tarun292facebook-github-bot
authored andcommitted
Make EValue template constructor MSVC friendly
Differential Revision: D65393407
1 parent 97a4600 commit ff8914d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

runtime/core/evalue.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,20 @@ struct EValue {
242242
// Template constructor that allows construction from types that can be
243243
// dereferenced to produce a type that EValue can be implicitly constructed
244244
// from.
245-
template <typename T>
246-
/*implicit*/ EValue(
247-
T&& value,
248-
typename std::enable_if<std::is_convertible<
249-
decltype(*std::forward<T>(value)),
250-
EValue>::value>::type* = 0) {
245+
template <typename T,
246+
typename = typename std::enable_if<
247+
std::is_convertible<
248+
decltype(*std::forward<T>(std::declval<T>())), // declval to simulate forwarding
249+
EValue
250+
>::value
251+
>::type>
252+
/*implicit*/ EValue(T&& value) {
251253
ET_CHECK_MSG(value != nullptr, "Pointer is null.");
252254
// Note that this ctor does not initialize this->tag directly; it is set by
253255
// moving in the new value.
254256
moveFrom(*std::forward<T>(value));
255-
}
257+
}
258+
256259

257260
// Delete constructor for raw pointers to ensure they cannot be used.
258261
template <typename T>

runtime/core/exec_aten/exec_aten.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#pragma once
1010

1111
#include <executorch/runtime/core/tensor_shape_dynamism.h> // @manual
12+
#include <executorch/runtime/platform/compiler.h>
1213
#ifdef USE_ATEN_LIB
1314
#include <ATen/Tensor.h> // @manual
1415
#include <c10/core/Device.h>

0 commit comments

Comments
 (0)