Skip to content

Design of Matrix class #1089

@kkarbowiak

Description

@kkarbowiak

Looks like the design of Matrix class could be improved. Here are some points:

  1. Matrix is a template class, but is only instantiated for uint32_t (in fact it's UserCost, UserDuration and UserDistance, but all boil down to the same type).
  2. The implementation is partly in source file, which requires explicit template instantiation (see:
    template class Matrix<UserCost>;
    ) to prevent linking errors. The instantation is for UserCost, which automatically works for UserDuration and UserDistance due to all three being an alias for uint32_t. Adding explicit instantiation for the latter two types for clarity results in compiler error (duplicate explicit instantiation of ‘class vroom::Matrix<unsigned int>’).
  3. Trying to reuse the class for any other type is not possible due to linker errors.
  4. The constructors could be cleaned up a bit.

I propose to leave Matrix as a template class but move the implementation entirely to the header file.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions