throw.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*=============================================================================
  2. Copyright (c) 2005-2007 Dan Marsden
  3. Copyright (c) 2005-2007 Joel de Guzman
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #ifndef PHOENIX_STATEMENT_THROW_HPP
  8. #define PHOENIX_STATEMENT_THROW_HPP
  9. #include <boost/spirit/home/phoenix/core/actor.hpp>
  10. #include <boost/spirit/home/phoenix/core/composite.hpp>
  11. #include <boost/spirit/home/phoenix/core/compose.hpp>
  12. #include <boost/mpl/bool.hpp>
  13. namespace boost { namespace phoenix {
  14. struct throw_new_eval
  15. {
  16. template<typename Env, typename ThrowExpr>
  17. struct result
  18. {
  19. typedef void type;
  20. };
  21. template<typename Rt, typename Env, typename ThrowExpr>
  22. static void
  23. eval(const Env& env, ThrowExpr& throwExpr)
  24. {
  25. throw throwExpr.eval(env);
  26. }
  27. };
  28. struct throw_again_eval
  29. {
  30. typedef mpl::false_ no_nullary;
  31. template<typename Env>
  32. struct result
  33. {
  34. typedef void type;
  35. };
  36. template<typename Env>
  37. void eval(const Env&) const
  38. {
  39. throw;
  40. }
  41. };
  42. inline actor<throw_again_eval> throw_()
  43. {
  44. return throw_again_eval();
  45. }
  46. template<typename Actor>
  47. actor<typename as_composite<throw_new_eval, Actor>::type>
  48. throw_(const Actor& a)
  49. {
  50. return compose<throw_new_eval>(a);
  51. }
  52. }}
  53. #endif