5

As far as I know, mixin is when you first write the derived class, and then you can inject the base class to it through a template parameter.

Example: http://www.drdobbs.com/cpp/mixin-based-programming-in-c/184404445

As I know Policy-based design is meant for the same. http://en.wikipedia.org/wiki/Policy-based_design

It doesn't say you should derive from it, you can use the template parameter other ways also. However, for example in Wikipedia Policy-based design example is something like this:

template<typename Base>
class Derive: private Base

Which is I think the same as mixin. (instead, that in mixins you usually use public inheritence)

Is there any significant difference between them or mixin is a special case of Policy-based design?

Divya Jain
  • 393
  • 1
  • 6
  • 22
Melkon
  • 418
  • 3
  • 12
  • 1
    This might help: http://stackoverflow.com/a/533675/1147772 – Drax Apr 09 '15 at 13:21
  • This is not related to my question. By the way as i know mixin mean a different thing in C++ than in any other language. – Melkon Apr 09 '15 at 14:12
  • 1
    A mixin is a principle, the way you implement it (multiple inheritance, template or not etc.) is just that, a way to implement it, as long as you get what you expect i don't think there is a "right" design for it, whether it is policy based or not :) – Drax Apr 10 '15 at 08:33

0 Answers0