On Sat, 05 Nov 2016 10:34:33 +0200, Paavo Helde wrote:
> The 'inline' is redundant in this example, it is just adding noise.
Thank you Paavo/ Why is it redundent here?
>
> Using 'cost' for a template type parameter seems disconcerting. To me,
> 'cost' is something which has e.g. value 12, not something which has a
> value like a type 'int'.
Like a constant instead of a template value? Why do you say that? FWIW, this
is supposed to eventually do the Fitch/Sankoff algorithm for Phylogenetics. I want
to template it so that I can cook up different mechanism for cost determination
on the same scafling of this work, and do some comparing.
> Maybe it should be named smth like
> CostCalculationPolicy? <== i really don't like long variable names. It is not
really the policy though, but the numeric value. I'm starting with ints, but I can
see possible needs for using floats later, or even get more flexible. I do see your
point though.
Quote<<A template is not a class. Template is a compile-time prescription for
making many classes. You cannot put templates into some concrete
std::vector as the templates exist only at compile time and a concrete
instance of std::vector exists only at run time.>>
What I thought would happen is that the compiler would substitute in the code,
first for the inner template, and then for the outer one, but I suppose that would
mean the g++ needs to do multiple passes in the compile, which it may, or may not do.
vector is also a template so it is also in existence on at compile time?
Is that right? Is there really no creation of a datatype called vector on compilation?
Are vectors run time embodiment in the stack, or on the heap
Quote<< Indeed, what you can do is to make another prescription (template) which
prescribes how to use your abstract class template with another abstract
class template (std::vector). It appears this is what you have.>>
Yeah I thought the compiler would pick that up without the explicit direction.
This is a big limitation.
Quote
<<Another option is to fix the template parameter, so that you get an
instantiated actual class:
void foo() {
std::vector<state<int>> vstate;
// vstate is an instance of a concrete class
}
>>
I think you lose your flexibility with state in that case.