Skip to content

Add compatibility check to istlVectorBackend()

Carsten Gräser requested to merge feature/check-field-types into master

This now checks if the provided container provides a unique field type and fails with a nice static_assert message if this is not the case. Hence you get much better diagnostic messages, if this is not the case. E.g.

using VelocityBitVector = std::vector<std::array<bool,dim> >;
using PressureBitVector = std::vector<bool>;
using BitVectorType = TupleVector<VelocityBitVector, PressureBitVector>;
auto v = BitVectorType{};
auto vBackend = Functions::istlVectorBackend(v);

will now fail with a nice error message because there's two different field types here: plain bool and the proxy-reference of std::vector<bool>. Unfortunately you cannot pass more data to the static_assert, not even constexpr functions are allowed. But you can trick the compiler to see the list of field types:

auto fieldTypeList = Dune::Functions::fieldTypes<BitVectorType>();
Dune::UnpackTypeList_t<std::tuple, decltype(fieldTypeList)>::printError();

Merge request reports