static_cast.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_STATIC_CAST_HPP
  7. #define PHOENIX_OBJECT_STATIC_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 static_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 static_cast<RT>(obj.eval(env));
  26. }
  27. };
  28. }
  29. template <typename T, typename U>
  30. inline actor<typename as_composite<impl::static_cast_eval<T>, U>::type>
  31. static_cast_(U const& obj)
  32. {
  33. return compose<impl::static_cast_eval<T> >(obj);
  34. }
  35. }}
  36. #endif