Skip to content

Commit

Permalink
Add static assert for generic lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbowen42 committed Sep 7, 2023
1 parent 9e2d1ea commit 25be698
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/serac/physics/heat_transfer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ class HeatTransfer<order, dim, Parameters<parameter_space...>, std::integer_sequ
struct ThermalMaterialIntegrand {
ThermalMaterialIntegrand(MaterialType material) : material_(material) {}

// The template parameter MaterialType is meant to be a callable functor. Due
// to nvcc's lack of support for generic lambdas (i.e. functions of the form
// auto lambda = [](auto) {}; ), this cannot be allowed. In order for this code
// to be portable to CUDA platforms, the asserts below prevent serac from compiling
// if such a lambda is supplied.
class DummyArgumentType {};
static_assert(!std::is_invocable<MaterialType, DummyArgumentType&>::value);
static_assert(!std::is_invocable<MaterialType, DummyArgumentType*>::value);
static_assert(!std::is_invocable<MaterialType, DummyArgumentType>::value);

template <typename X, typename T, typename dT_dt, typename Shape, typename... Params>
auto operator()(X x, T temperature, dT_dt dtemp_dt, Shape shape, Params... params)
{
Expand Down

0 comments on commit 25be698

Please sign in to comment.