Skip to content

Remove XyzElement template layer

Marco Clemencic requested to merge remove-unneeded-template-level into master

The usual patter to define specialized detector elements is:

namespace LHCb::Detector::MyDet {
  namespace detail {
    struct MyDetObject : ... { ... };
  }
  template <ObjectType>
  struct MyDetElement : DeIOVElement<ObjectType> { ... };
  using MyDet = MyDetElement<detail::MyDetObject>;
}

that has the big disadvantage that the methods of MyDetElement are instantiated only when they are actually used, which means that one can write in them any syntactically correct garbage and the compiler will report problems only later giving the false impression that the code is correct while it is not.

Since we never need MyDetElement with any other template argument than detail::MyDetObject, we can remove this level of template indirection and write:

namespace LHCb::Detector::MyDet {
  namespace detail {
    struct MyDetObject : ... { ... };
  }
  struct MyDet : DeIOVElement<detail::MyDetObject> { ... };
}

which forces the compiler to instantiate the methods and expose problems.

This MR applies the suggested change and fixes the problems that are exposed by the change.

Note that I didn't touch UT code as the change uncovered too many issues in the code and I do not know how to address them.

Edited by Marco Clemencic

Merge request reports

Loading