Re: static polymorphism --- How it actually Happens ?
* Pallav singh:
Can anyone explain How it actually Happens ?
Your assumption that readers are telepathic is pretty stupid. *What* is it that
you wonder how happens?
polymorphic behaviour needed is invariant and can be determined at
compile time.
If you says so.
Then the Curiously Recurring Template Pattern (CRTP) can be used to
achieve static polymorphism, which is an imitation of polymorphism
"imitation of polymorphism" is a meaningless phrase.
in
programming code
"programming code" is a meaningless phrase.
but which is resolved at compile time
There is apparently no contradiction with what you've written earlier, so it
seems that the "but" is meaningless.
and thus does
away with run-time virtual-table lookups.
That conclusion is incorrect. "Does not require" does not mean the same as "does
away with".
template <class Derived>
struct base
{
void interface()
{
// ...
static_cast<Derived*>(this)->implementation();
// ...
}
};
struct derived : base<derived>
{
void implementation();
};
What is the question?
Cheers & hth.,
- Alf
--
Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! :-) Just going there is good. Linking
to it is even better! Thanks in advance!