policy-based-design

Does static polymorphism make sense for implementing an interface?

孤者浪人 提交于 2019-11-29 10:52:21
and Merry Christmas everybody! I am learning about static polymorphism and I'm reading Andrei Alexandrescu's excellent book on policy-based design. I came across the following, in my code: I have interface Interface which specifies that method Foo must be present. This interface will be implemented by class Impl . I have the following two options: 1) Dynamic polymorphism class Interface { public: virtual void Foo() = 0; } class Impl : public Interface { public: void Foo() {}; } 2) Static polymorphism class Impl { { public: void Foo() {}; } template <class I> class Interface : public I { public

Does static polymorphism make sense for implementing an interface?

孤人 提交于 2019-11-28 04:25:40
问题 and Merry Christmas everybody! I am learning about static polymorphism and I'm reading Andrei Alexandrescu's excellent book on policy-based design. I came across the following, in my code: I have interface Interface which specifies that method Foo must be present. This interface will be implemented by class Impl . I have the following two options: 1) Dynamic polymorphism class Interface { public: virtual void Foo() = 0; } class Impl : public Interface { public: void Foo() {}; } 2) Static

How to use typelists

白昼怎懂夜的黑 提交于 2019-11-26 20:18:25
问题 I read about typelists in 'Modern C++ Design' and I understood it as some kind of union for types. By putting diffrent, non-related types in a typelist, one can use it to represent more than one type at once, without inheritance. I tested typelist in some simple functions with primitive types, but I couldn't get any of them to work. Could someone tell me if my unterstanding of typelists is right and give an simple real world example how to use typelists in every day average code? Thanks in