Skip to content

Commit 9abc323

Browse files
committed
AST: add a workaround for VS2017
Unfortunately, VS2017 does not support the SFINAE expression. This means that it attempts to parse the `Index < sizeof...(Types)` as a template parameter resulting in a parse failure. This normalises the constraint to `0 < sizeof...(Types) - Index` (`sizeof...(Types) - Index > 0`) which is then wrapped into a ternary to explicitly convert it to a boolean. This repairs the builds on VS2017.
1 parent f886945 commit 9abc323

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/swift/AST/SimpleRequest.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ namespace detail {
113113

114114
/// Extract the first, nearest source location from a tuple.
115115
template<unsigned Index, typename ...Types,
116-
typename = typename std::enable_if<Index < sizeof...(Types)>::type>
116+
typename = typename std::enable_if<sizeof...(Types) - Index
117+
? true
118+
: false>::type>
117119
SourceLoc extractNearestSourceLocTuple(const std::tuple<Types...> &value) {
118120
SourceLoc loc = maybeExtractNearestSourceLoc(std::get<Index>(value));
119121
if (loc.isValid())

0 commit comments

Comments
 (0)