Looks like the design of Matrix class could be improved. Here are some points:
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).
- 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>’).
- Trying to reuse the class for any other type is not possible due to linker errors.
- 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.
Looks like the design of
Matrixclass could be improved. Here are some points:Matrixis a template class, but is only instantiated foruint32_t(in fact it'sUserCost,UserDurationandUserDistance, but all boil down to the same type).vroom/src/structures/generic/matrix.cpp
Line 36 in 176f57a
UserCost, which automatically works forUserDurationandUserDistancedue to all three being an alias foruint32_t. Adding explicit instantiation for the latter two types for clarity results in compiler error (duplicate explicit instantiation of ‘class vroom::Matrix<unsigned int>’).I propose to leave
Matrixas a template class but move the implementation entirely to the header file.