mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-08 03:18:58 +00:00
c41c3b7a57
`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. |
||
---|---|---|
.. | ||
arg | ||
cuda | ||
internal | ||
kokkos | ||
openmp | ||
serial | ||
tbb | ||
testing | ||
AtomicArrayExecutionObject.h | ||
BoundaryState.h | ||
CellDerivative.h | ||
CellEdge.h | ||
CellFace.h | ||
CellInside.h | ||
CellInterpolate.h | ||
CellLocator.h | ||
CellLocatorBoundingIntervalHierarchy.h | ||
CellLocatorMultiplexer.h | ||
CellLocatorRectilinearGrid.h | ||
CellLocatorTwoLevel.h | ||
CellLocatorUniformGrid.h | ||
CellMeasure.h | ||
CMakeLists.txt | ||
ColorTable.h | ||
ColorTable.hxx | ||
ConnectivityExplicit.h | ||
ConnectivityExtrude.h | ||
ConnectivityPermuted.h | ||
ConnectivityStructured.h | ||
ExecutionWholeArray.h | ||
FieldNeighborhood.h | ||
FunctorBase.h | ||
ParametricCoordinates.h | ||
PointLocator.h | ||
PointLocatorSparseGrid.h | ||
TaskBase.h |