I received a very large code, in which there is a class template <int dim> class point
which works like a vector
.
Since that class is involved (in a cascade manner) in many other classes, methods, etc., it forces those other classes, etc., to be templates with the same integral constant expression as a class template non-type argument.
For instance, there is class D
, to which I want to add:
void D::coords(const point<dim>&)
.void D::verif(const source<dim>&)
.
Here source
is a base class (could be abstract), with a huge hierarchy of its own, which uses point
in one of its methods.
In this case, I guess I am forced to convert D
and all its derived hierarchy of classes to templates, which means modifying hundreds of sources/headers, at many points.
This addition would be much simpler if class point
used dim
as a class member instead of a template argument.
I would simply add the method in D.h
and D.cc
.
In all parts of the code that I saw, there is no occasion in which such change would not provide the same functionality.
Before I delve into the attempt to such huge modification, once and for all, I want to know...
What are possible uses of an integral constant expression as a class template non-type argument that are not replaceable by a class member? I guess there should be some, and I welcome all possible examples. This might help me understanding the options I have (perhaps none!)
Alternatively (option B?),
Is there a way of making the intended additions, which does not require the huge modifications I foresee, but only the additions in D.h
and D.cc
?