Metaprogramming + Multiple Inheritance?
Dear all, I am looking for problems a reasonable design for solving which requires mixing (template/preprocessor) metaprogramming and multiple inheritance, say for a single class. In particular, has any part of the Boost library been designed with this mixture? TIA,--Hossein
2011/9/4 Hossein Haeri
Dear all,
I am looking for problems a reasonable design for solving which requires mixing (template/preprocessor) metaprogramming and multiple inheritance, say for a single class.
The combination of multiple inheritance and generic programming using templates is described in the book Andrei Alexandrescu (2001) Modern C++ Design. and is called "Policy-Based Design" there.
In particular, has any part of the Boost library been designed with this mixture?
As far as I know, mixing multiple inheritance with meta programming techniques in general and Policy-Based Design in particular is not a major trend in boost (others may correct me, if I'm wrong). More dominant are designs using static polymorphism via metaprogramming without (multiple) inheritance based on the notion of "concepts". Such designs are working similar to the approach described in Jaakko Järvi, et.al: Concept-Controlled Polymorphism see https://parasol.tamu.edu/~jarvi/papers/concept-controlled.pdf HTH Joachim -- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de
on Sun Sep 04 2011, Hossein Haeri
Dear all, I am looking for problems a reasonable design for solving which requires mixing (template/preprocessor) metaprogramming and multiple inheritance, say for a single class. In particular, has any part of the Boost library been designed with this mixture? TIA,--Hossein
The classic example is the implementation of a visitor. See Alexandrescu's "Modern C++ Design" for an extensive discussion. -- Dave Abrahams BoostPro Computing http://www.boostpro.com
Hi Dave,
There is a fine line between Generic Programming in general and metaprogramming. My personal feeling is that Andrei's works -- and PBD in general -- are good instances for Generic Programming. Yet, I don't seem to register them per se as metaprogramming. I understand that this might be a very personal viewpoint. I say this because I had a try and couldn't quite put my reasons into words. Anyhow, thank you for reminding me of Andrei's Visitor implementations. Other examples (outside his book)?
TIA,--Hossein
--- On Sun, 4/9/11, Dave Abrahams
Dear all, I am looking for problems a reasonable design for solving which requires mixing (template/preprocessor) metaprogramming and multiple inheritance, say for a single class. In particular, has any part of the Boost library been designed with this mixture? TIA,--Hossein
The classic example is the implementation of a visitor. See Alexandrescu's "Modern C++ Design" for an extensive discussion. -- Dave Abrahams BoostPro Computing http://www.boostpro.com _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
on Sun Sep 04 2011, Hossein Haeri
Hi Dave, There is a fine line between Generic Programming in general and metaprogramming. My personal feeling is that Andrei's works -- and PBD in general -- are good instances for Generic Programming. Yet, I don't seem to register them per se as metaprogramming. I understand that this might be a very personal viewpoint. I say this because I had a try and couldn't quite put my reasons into words.
Andrei isn't focusing on metaprogramming (nor on generic programming as I understand the term); but he is _applying_ metaprogramming techniques to classic OO design patterns (such as visitor). As such that makes a very good example of what you're asking about. -- Dave Abrahams BoostPro Computing http://www.boostpro.com
2011/9/5 Dave Abrahams
on Sun Sep 04 2011, Hossein Haeri
wrote: Hi Dave, There is a fine line between Generic Programming in general and metaprogramming. My personal feeling is that Andrei's works -- and PBD in general -- are good instances for Generic Programming. Yet, I don't seem to register them per se as metaprogramming. I understand that this might be a very personal viewpoint. I say this because I had a try and couldn't quite put my reasons into words.
Andrei isn't focusing on metaprogramming (nor on generic programming as I understand the term); but he is _applying_ metaprogramming techniques to classic OO design patterns (such as visitor). As such that makes a very good example of what you're asking about.
Another brilliant combination of metaprogramming and multiple inheritance is Andrei's example on generating classes and class hierarchies from typelists [1](pp. 64-76). This technique is not only a nifty way of using metaprogramming. I also found it very useful for defining a polymorphic tuple class template. I used this approach to implement an axiom based test machine [2], where the tuple of free variables (of arbitrary types) that occur in an axiom are implemented using Andrei's typelist generated class approach. https://svn.boost.org/svn/boost/sandbox/icl/boost/validate/loki_xt/Tuple.h Cheers, Joachim [1] Alexandrescu, Andrei: Modern C++ Design. Addison-Wesley, 2001. [2] Joachim Faulhaber: Boost.Alabaster. A Law Based Tester, BoostCon 2010. https://svn.boost.org/svn/boost/sandbox/icl/libs/validate/doc/boostcon2010/B... -- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de
Yes Joachim, these are good examples. Thanks. :)
--- On Mon, 5/9/11, Joachim Faulhaber
on Sun Sep 04 2011, Hossein Haeri
wrote: Hi Dave, There is a fine line between Generic Programming in general and metaprogramming. My personal feeling is that Andrei's works -- and PBD in general -- are good instances for Generic Programming. Yet, I don't seem to register them per se as metaprogramming. I understand that this might be a very personal viewpoint. I say this because I had a try and couldn't quite put my reasons into words.
Andrei isn't focusing on metaprogramming (nor on generic programming as I understand the term); but he is _applying_ metaprogramming techniques to classic OO design patterns (such as visitor). As such that makes a very good example of what you're asking about.
Another brilliant combination of metaprogramming and multiple inheritance is Andrei's example on generating classes and class hierarchies from typelists [1](pp. 64-76). This technique is not only a nifty way of using metaprogramming. I also found it very useful for defining a polymorphic tuple class template. I used this approach to implement an axiom based test machine [2], where the tuple of free variables (of arbitrary types) that occur in an axiom are implemented using Andrei's typelist generated class approach. https://svn.boost.org/svn/boost/sandbox/icl/boost/validate/loki_xt/Tuple.h Cheers, Joachim [1] Alexandrescu, Andrei: Modern C++ Design. Addison-Wesley, 2001. [2] Joachim Faulhaber: Boost.Alabaster. A Law Based Tester, BoostCon 2010. https://svn.boost.org/svn/boost/sandbox/icl/libs/validate/doc/boostcon2010/B... -- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Dave Abrahams
-
Hossein Haeri
-
Joachim Faulhaber