Boost provides free peer-reviewed portable C++ source libraries.
We emphasize libraries that work
源代码在线查看: if.hpp
/*============================================================================= 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 operator[](Else const& else_) const { return compose( fusion::at_c(source) // cond , fusion::at_c(source) // then , else_ // else ); } if_composite const& source; }; template struct if_composite : composite { if_composite(Cond const& cond, Then const& then) : composite(cond, then) , else_(*this) {} else_gen else_; }; template struct if_gen { if_gen(Cond const& cond) : cond(cond) {} template actor operator[](Then const& then) const { return actor( cond, as_actor::convert(then)); } Cond cond; }; template inline if_gen if_(Cond const& cond) { return if_gen( as_actor::convert(cond)); } }} #if defined(BOOST_MSVC) # pragma warning(pop) #endif #endif