Update contrib.
1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file conditional.hpp
3 /// A special-purpose proto compiler for compiling an expression either one
4 /// way or another depending on the properties of the expression.
6 // Copyright 2004 Eric Niebler. Distributed under the Boost
7 // Software License, Version 1.0. (See accompanying file
8 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_PROTO_COMPILER_CONDITIONAL_HPP_EAN_04_01_2005
11 #define BOOST_PROTO_COMPILER_CONDITIONAL_HPP_EAN_04_01_2005
13 #include <boost/mpl/if.hpp>
14 #include <boost/mpl/bool.hpp>
15 #include <boost/xpressive/proto/proto_fwd.hpp>
17 namespace boost { namespace proto
20 ///////////////////////////////////////////////////////////////////////////////
21 // conditional_compiler
22 template<typename Predicate, typename IfCompiler, typename ElseCompiler>
23 struct conditional_compiler
25 template<typename Op, typename State, typename Visitor>
28 typedef typename boost::mpl::if_
30 typename Predicate::BOOST_NESTED_TEMPLATE apply<Op, State, Visitor>::type
33 >::type compiler_type;
35 typedef typename compiler_type::BOOST_NESTED_TEMPLATE apply
43 template<typename Op, typename State, typename Visitor>
44 static typename apply<Op, State, Visitor>::type
45 call(Op const &op, State const &state, Visitor &visitor)
47 typedef typename apply<Op, State, Visitor>::compiler_type compiler_type;
48 return compiler_type::call(op, state, visitor);