/src/contrib/boost/spirit/home/phoenix/object/dynamic_cast.hpp

http://pythonocc.googlecode.com/ · C++ Header · 42 lines · 31 code · 5 blank · 6 comment · 0 complexity · f3255a2c38c7cfb7ec3eeb3a5ea31758 MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #ifndef PHOENIX_OBJECT_DYNAMIC_CAST_HPP
  7. #define PHOENIX_OBJECT_DYNAMIC_CAST_HPP
  8. #include <boost/spirit/home/phoenix/core/compose.hpp>
  9. namespace boost { namespace phoenix
  10. {
  11. namespace impl
  12. {
  13. template <typename T>
  14. struct dynamic_cast_eval
  15. {
  16. template <typename Env, typename U>
  17. struct result
  18. {
  19. typedef T type;
  20. };
  21. template <typename RT, typename Env, typename U>
  22. static RT
  23. eval(Env const& env, U& obj)
  24. {
  25. return dynamic_cast<RT>(obj.eval(env));
  26. }
  27. };
  28. }
  29. template <typename T, typename U>
  30. inline actor<typename as_composite<impl::dynamic_cast_eval<T>, U>::type>
  31. dynamic_cast_(U const& obj)
  32. {
  33. return compose<impl::dynamic_cast_eval<T> >(obj);
  34. }
  35. }}
  36. #endif