/*============================================================================= Copyright (c) 2001-2007 Joel de Guzman Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef PHOENIX_STATEMENT_IF_HPP #define PHOENIX_STATEMENT_IF_HPP #include #include #include #if defined(BOOST_MSVC) # pragma warning(push) # pragma warning(disable:4355) #endif namespace boost { namespace phoenix { struct if_else_eval { template struct result { typedef void type; }; template < typename RT, typename Env , typename Cond, typename Then, typename Else> static void eval(Env const& env, Cond& cond, Then& then, Else& else_) { if (cond.eval(env)) then.eval(env); else else_.eval(env); } }; struct if_eval { template struct result { typedef void type; }; template static void eval(Env const& env, Cond& cond, Then& then) { if (cond.eval(env)) then.eval(env); } }; template struct if_composite; template struct else_gen { else_gen(if_composite const& source) : source(source) {} template actor::type> operator[](Else const& else_) const { return compose( fusion::at_c<0>(source) // cond , fusion::at_c<1>(source) // then , else_ // else ); } if_composite const& source; private: // silence MSVC warning C4512: assignment operator could not be generated else_gen& operator= (else_gen const&); }; template struct if_composite : composite > { if_composite(Cond const& cond, Then const& then) : composite >(cond, then) , else_(*this) {} else_gen else_; private: // silence MSVC warning C4512: assignment operator could not be generated if_composite& operator= (if_composite const&); }; template struct if_gen { if_gen(Cond const& cond) : cond(cond) {} template actor::type> > operator[](Then const& then) const { return actor::type> >( cond, as_actor::convert(then)); } Cond cond; }; template inline if_gen::type> if_(Cond const& cond) { return if_gen::type>( as_actor::convert(cond)); } }} #if defined(BOOST_MSVC) # pragma warning(pop) #endif #endif