// file : Utility/Hetero/Shell.hpp // author : Boris Kolpackov // copyright : Copyright (c) 2002-2003 Boris Kolpackov // license : http://kolpackov.net/license.html #ifndef UTILITY_HETERO_SHELL_HPP #define UTILITY_HETERO_SHELL_HPP namespace Utility { namespace Hetero { // // // class ShellCore { protected: template static typename F::RetType apply (F& f, TypedContainer >& c) { if (type_check (c)) return type_apply (f, c); throw Utility::Hetero::Typing (); } template static typename F::RetType apply (F& f, TypedContainer >& c) { if (type_check (c)) return type_apply (f, c); if (type_check (c)) return type_apply (f, c); throw Utility::Hetero::Typing (); } template static typename F::RetType apply (F& f, TypedContainer >& c) { if (type_check (c)) return type_apply (f, c); if (type_check (c)) return type_apply (f, c); if (type_check (c)) return type_apply (f, c); throw Utility::Hetero::Typing (); } private: template static bool type_check (Container& c) { return c.type () == typeid (T); } template static typename F::RetType type_apply (F& f, Container& c) { return f (c. template value ()); } }; // // // template struct Shell : F, ShellCore { using F::operator (); template typename F::RetType operator () (TypedContainer& p) { return apply (*this, p); } }; } } #endif // UTILITY_HETERO_SHELL_HPP //$Id$