Can anyone kindly explain why non-type template parameters are
required by giving some examples where their uses are clearly
favourable to other alternatives?
I cannot think of any good use for them except to create different
sizes of static arrays from a template, but this could be done by
creating a dynamic array of different sizes accepting the sizes in the
constructor thus not requiring the use of non-type template parameters
and the dynamic array approach seems to be a better choice to my eyes.
(It's just my feeling. I do not know which is better. But it's not the
important issue here).
I know my inability to think of good uses of non-type template
parameters is due to my lack of experience and if the feature is
included in the language, it must be there for a good reason. So can
anyone help me learn to use this feature properly? Thank you very much
in advance!
P.S I am begining to enjoy learning C++ but I sometimes find hard to
appreciate certain features. Is there any book which explains the
language features with realistic design and implementation examples,
not with those crafted examples just for the sake of explaining the
features? Thank you always!