On Saturday, 16 February 2013 00:18:44 UTC+2, Cholo Lennon wrote:
> On 02/15/2013 03:03 PM, Öö Tiib wrote:
> > On Friday, 15 February 2013 19:25:10 UTC+2, Cholo Lennon wrote:
> >> On 02/15/2013 02:05 PM, Öö Tiib wrote:
> >>> On Friday, 15 February 2013 18:55:12 UTC+2, Cholo Lennon wrote:
> >>>> On 02/15/2013 01:33 PM, Öö Tiib wrote:
> >>>>> On Friday, 15 February 2013 18:18:47 UTC+2, Cholo Lennon wrote:
> >>>>>> How about this?
> >>>>>
> >>>>> It is example that works but does not achieve much else but inefficiency.
> >>>>> 
> >>>>
> >>>> Why the example is inefficient? The call to Derived:
nStatic is
> >>>> resolved at compile time.
> >>>
> >>> Because there are virtual functions (more expensive) that can not be used for
> >>> dynamic polymorphism (purpose is lost).
> >>> I explained it further. In my post that you quoted but apparently didnot read.
> >>
> >> and... have you read my explanation? This was an *example*, not a
> >> production code. The idea was to show the dynamic and static variant in
> >> a simple way.
> >
> > I do not, yes, understand something here. Can you elaborate? Example must
> > be ideally simplest that works. Simpler than that is a lie, not example..
> > Someone may see it and think that it is showing how to mix dynamic and static
> > polymorphism, but it can't. What production code? I was saying that it should
> > be example on "never do like that" page with large red cross on it.
> >
>
> OMG, the OP asked for an example of static polymorphism with CRTP and
> you gave him an example of static polymorphism with templates but
> without CRTP! Nice way to teach the concept!
The concept we discussed before. CRTP is just one pattern for to use static
polymorphism, but that I said to him in my first reply already.
Now he was asking what to do with the resulting with CRTP functions that
have same signature (he said are "similar") but do not belong to same virtual
hierarchy (he said are not "same"). So I said that he should continue using
static polymorphism.
> Just in case you insist with my example, I re-wrote it for you:
Thanks.
> Are you happy now?
Sometimes people see me more grumpy than I really am. I try to point out the
flaws to be helpful. Everything contains mistakes, mine code too, yours was
not making me unhappy or anything.
Mixing static and dynamic polymorphism may be needed in same application.
For example if you need a container that contains polymorphic pointers then
there you have to use dynamic polymorphism, static does not work.