vtk-m2/vtkm/exec/internal
Kenneth Moreland c41c3b7a57 Fix Variant::CastAndCall SFINAE for auto return type functors
`Variant::CastAndCall` was using the C++11 style for an `auto` return
where the return type was specified with a `->` that got the `decltype`
of the return value of the functor. This was used as part of SFINAE to
pick whether you needed the const or non-const version.

However, this was causing a problem with functions that got an error
when deducing the return type for that. This was particularly
problematic for lambda functions. For example, say you have the
following simple `CastAndCall`.

```cpp
variant.CastAndCall([](auto& x){ ++x; });
```

To determine the return type of the lambda (`void`), the function has to
be compiled. But when it is compiled with a const type, which happens
when deducing the const version of `CastAndCall`, you get a compile
error. This error is not considered a substitution error (hence SFINAE),
it is an outright error. So you get a compile error just trying to
deduce the type.

The solution was to move to the C++14 version of an auto return type. In
this case, the return type is no longer important for SFINAE and is
delayed until the function is actually compiled with the specific
template parameters. This would be a problem if the const version of
`CastAndCall` was used when the non-const version was needed. But now
both versions will pass SFINAE and thus the non-const version will be
chosen as long as the `Variant` object itself is non-const. If the
`Variant` object itself is const, then that is in fact a legitimate
error, so a compile error is OK.

One thing I find wierd is that `CastAndCall` still has a `noexcept`
expression that will likewise cause a compile error in this case.
However, it is still working. I _think_ the difference is that
`noexcept` is not used to determine template substitution/overloaded, so
is therefore ignored until the function is actually compiled.
2022-07-29 06:50:34 -06:00
..
testing Fix Variant::CastAndCall SFINAE for auto return type functors 2022-07-29 06:50:34 -06:00
.gitattributes clang-format: apply to the entire tree 2017-05-25 07:51:37 -04:00
CMakeLists.txt cmake: avoid adding testing directories if testing is disabled 2021-06-01 18:40:40 -04:00
ErrorMessageBuffer.h Correct symbol visibility issues found by ubsan testing 2019-09-11 08:30:49 -04:00
FastVec.h conslidate the license statement 2019-04-17 10:57:13 -06:00
ReduceByKeyLookup.h Add non-templated base class to Keys class. 2020-05-21 08:34:07 -06:00
TaskSingular.h Remove ArrayHandleStreaming capabilities 2020-03-24 15:01:56 -06:00
TwoLevelUniformGridExecutionObject.h Deprecate ArrayHandle::ExecutionTypes 2021-02-08 12:17:37 -07:00
Variant.h Make separate exec and cont versions of Variant 2020-11-09 12:48:10 -07:00
WorkletInvokeFunctorDetail.h relaxes ThreadIndicesType across multiple worklets fetchs 2020-04-24 17:39:31 -04:00
WorkletInvokeFunctorDetail.h.in relaxes ThreadIndicesType across multiple worklets fetchs 2020-04-24 17:39:31 -04:00