milena r1739: Conditionnal heritage exercice

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2008-02-19 Etienne FOLIO <folio@lrde.epita.fr> Conditionnal heritage exercice. * sandbox/folio/heritage_conditionnel.cc: Test file. * sandbox/folio/heritage_conditionnel.hh: Exercice implementation. --- heritage_conditionnel.cc | 7 +++++++ heritage_conditionnel.hh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) Index: trunk/milena/sandbox/folio/heritage_conditionnel.cc =================================================================== --- trunk/milena/sandbox/folio/heritage_conditionnel.cc (revision 0) +++ trunk/milena/sandbox/folio/heritage_conditionnel.cc (revision 1739) @@ -0,0 +1,7 @@ +#include "heritage_conditionnel.hh" + +int main() +{ + new Bottom<1 == 1>(); + new Bottom<1 == 0>(); +} Index: trunk/milena/sandbox/folio/heritage_conditionnel.hh =================================================================== --- trunk/milena/sandbox/folio/heritage_conditionnel.hh (revision 0) +++ trunk/milena/sandbox/folio/heritage_conditionnel.hh (revision 1739) @@ -0,0 +1,46 @@ +#ifndef HERITAGE_CONDITIONNEL_HH_ +# define HERITAGE_CONDITIONNEL_HH_ + +# include <iostream> + +class TopLeft +{ +protected: + TopLeft() + { + std::cout << "top left" << std::endl; + } +}; + +class TopRight +{ +protected: + TopRight() + { + std::cout << "top right" << std::endl; + } +}; + +template<bool C, typename T, typename U> +struct TraitCond +{ + typedef T type; +}; + +template<typename T, typename U> +struct TraitCond<false, T, U> +{ + typedef U type; +}; + +template<bool B> +class Bottom: public TraitCond<B, TopLeft, TopRight>::type +{ +public: + Bottom() + : TraitCond<B, TopLeft, TopRight>::type() + { + } +}; + +#endif /* !HERITAGE_CONDITIONNEL_HH_ */
participants (1)
-
Etienne FOLIO