PageRenderTime 28ms CodeModel.GetById 16ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/spirit/home/phoenix/statement/detail/switch_eval.hpp

http://hadesmem.googlecode.com/
C++ Header | 111 lines | 95 code | 9 blank | 7 comment | 2 complexity | c6d6c9ac3b7a0645c5d73fc9cebb65b0 MD5 | raw file
  1/*=============================================================================
  2    Copyright (c) 2001-2007 Joel de Guzman
  3
  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_DETAIL_SWITCH_EVAL_HPP
  8#define PHOENIX_STATEMENT_DETAIL_SWITCH_EVAL_HPP
  9
 10namespace boost { namespace phoenix { namespace detail
 11{
 12    template <int N>
 13    struct switch_eval;
 14
 15    template <>
 16    struct switch_eval<0>
 17    {
 18        template <
 19            typename Env, typename Cond, typename Default
 20        >
 21        struct result
 22        {
 23            typedef void type;
 24        };
 25
 26        template <
 27            typename RT, typename Env, typename Cond, typename Default
 28        >
 29        static void
 30        eval(
 31            Env const& env, Cond& cond, Default& default_
 32        )
 33        {
 34            default_.eval(env);
 35        }
 36    };
 37
 38    template <>
 39    struct switch_eval<1>
 40    {
 41        template <
 42            typename Env, typename Cond, typename Default
 43          , typename Case0
 44        >
 45        struct result
 46        {
 47            typedef void type;
 48        };
 49
 50        template <
 51            typename RT, typename Env, typename Cond, typename Default
 52          , typename Case0
 53        >
 54        static void
 55        eval(
 56            Env const& env, Cond& cond, Default& default_
 57          , Case0& _0
 58        )
 59        {
 60            switch (cond.eval(env))
 61            {
 62                case Case0::value:
 63                    _0.eval(env);
 64                    break;
 65                default:
 66                    default_.eval(env);
 67            }
 68        }
 69    };
 70
 71    template <>
 72    struct switch_eval<2>
 73    {
 74        template <
 75            typename Env, typename Cond, typename Default
 76          , typename Case0, typename Case1
 77        >
 78        struct result
 79        {
 80            typedef void type;
 81        };
 82
 83        template <
 84            typename RT, typename Env, typename Cond, typename Default
 85          , typename Case0, typename Case1
 86        >
 87        static void
 88        eval(
 89            Env const& env, Cond& cond, Default& default_
 90          , Case0& _0, Case1& _1
 91        )
 92        {
 93            switch (cond.eval(env))
 94            {
 95                case Case0::value:
 96                    _0.eval(env);
 97                    break;
 98                case Case1::value:
 99                    _1.eval(env);
100                    break;
101                default:
102                    default_.eval(env);
103            }
104        }
105    };
106
107    //  Bring in the rest of the switch_evals
108    #include <boost/spirit/home/phoenix/statement/detail/switch_eval.ipp>
109}}}
110
111#endif