Skip to content

Contrain GeometryType template constructor

The templated constructor is supposed to be used with types modelling a TopologyType, i.e., types providing ::dimension and ::id. This MR constrains the overload to such types only.

This fixes the problem that dune-functions cannot be build with clang and libstdc++-6. For the same reason the PQkLocalFiniteElementCache could not be used with this combination which is unfortunately not triggered by any test.

Since the reason is far from obvious I'll give a short summary:

  • Dune-functions uses PQkLocalFiniteElementCache.
  • The copy constructor and get() function of PQkLocalFiniteElementCache use operator[](const GeometryType&) of std::map<GeometryType,Foo>.
  • When called with an l-value, the operator[] of an std::map<T, Foo> checks if T can be constructed from a tuple<...>. (*)
  • This check fails to compile with the very greedy templated constructor
template<class TopologyType> GeometryType(TopologyType);

Notice that I don't understand the purpose of the check in (*) which spans over about 20 levels of template instantiation context. E.g. it does not happen if operator[] is called with an r-value as argument.

By constraining the constructor to only be available for appropriate types we can avoid this problem.

Merge request reports