/src/contrib/boost/spirit/home/phoenix/statement/do_while.hpp

http://pythonocc.googlecode.com/ · C++ Header · 62 lines · 47 code · 9 blank · 6 comment · 1 complexity · 8293973d5e124a5b4c86f5d4c70be93d 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_STATEMENT_DO_WHILE_HPP
  7. #define PHOENIX_STATEMENT_DO_WHILE_HPP
  8. #include <boost/spirit/home/phoenix/core/composite.hpp>
  9. #include <boost/spirit/home/phoenix/core/compose.hpp>
  10. namespace boost { namespace phoenix
  11. {
  12. struct do_while_eval
  13. {
  14. template <typename Env, typename Cond, typename Do>
  15. struct result
  16. {
  17. typedef void type;
  18. };
  19. template <typename RT, typename Env, typename Cond, typename Do>
  20. static void
  21. eval(Env const& env, Cond& cond, Do& do_)
  22. {
  23. do
  24. do_.eval(env);
  25. while (cond.eval(env));
  26. }
  27. };
  28. template <typename Do>
  29. struct do_while_gen
  30. {
  31. do_while_gen(Do const& do_)
  32. : do_(do_) {}
  33. template <typename Cond>
  34. actor<typename as_composite<do_while_eval, Cond, Do>::type>
  35. while_(Cond const& cond) const
  36. {
  37. return compose<do_while_eval>(cond, do_);
  38. }
  39. Do do_;
  40. };
  41. struct do_gen
  42. {
  43. template <typename Do>
  44. do_while_gen<Do>
  45. operator[](Do const& do_) const
  46. {
  47. return do_while_gen<Do>(do_);
  48. }
  49. };
  50. do_gen const do_ = do_gen();
  51. }}
  52. #endif