/*============================================================================= Copyright (c) 2005-2007 Dan Marsden Copyright (c) 2005-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_TRY_CATCH_HPP #define PHOENIX_STATEMENT_TRY_CATCH_HPP #include #include #include #include #include #include #include #if defined(BOOST_MSVC) # pragma warning(push) # pragma warning(disable:4355) #endif namespace boost { namespace phoenix { template struct try_catch_composite; namespace meta { template struct try_catch_composite_push_back { typedef typename Composite::base_type actor_tuple; typedef try_catch_composite< typename fusion::result_of::as_vector< typename fusion::result_of::push_back< actor_tuple, Actor>::type>::type> type; }; template struct catch_all_composite_push_back { typedef typename Composite::base_type actor_tuple; typedef composite< catch_all_eval, typename fusion::result_of::as_vector< typename fusion::result_of::push_back< actor_tuple, Actor>::type>::type> type; }; } namespace detail { struct try_catch_composite_push_back { template struct result : meta::try_catch_composite_push_back {}; template typename result::type operator()( const Composite& composite, const Actor& actor) const { typedef typename result::type result; return result( fusion::as_vector( fusion::push_back(composite, actor))); } }; struct catch_all_composite_push_back { template struct result : meta::catch_all_composite_push_back {}; template typename result::type operator()( const Composite& composite, const Actor& actor) const { typedef typename result::type result; return result( fusion::as_vector( fusion::push_back(composite, actor))); } }; } detail::try_catch_composite_push_back const try_catch_composite_push_back = detail::try_catch_composite_push_back(); detail::catch_all_composite_push_back const catch_all_composite_push_back = detail::catch_all_composite_push_back(); template struct catch_gen { explicit catch_gen( const SourceComposite& sourceComposite) : mSourceComposite(sourceComposite) { } template actor >::type> operator[](const Actor& actor) const { return try_catch_composite_push_back( mSourceComposite, detail::catch_composite(actor)); } const SourceComposite& mSourceComposite; }; template struct catch_all_gen { explicit catch_all_gen( const SourceComposite& sourceComposite) : mSourceComposite(sourceComposite) { } template actor::type> operator[](const Actor& actor) const { return catch_all_composite_push_back( mSourceComposite, actor); } const SourceComposite& mSourceComposite; }; template struct try_catch_composite : composite { explicit try_catch_composite( const Tuple& t) : composite(t), catch_all(*this) { } try_catch_composite( const try_catch_composite& rhs) : composite(rhs), catch_all(*this) { } template catch_gen catch_() const { return catch_gen( *this); } const catch_all_gen catch_all; private: try_catch_composite& operator=(const try_catch_composite&); }; struct try_gen { template try_catch_composite > operator[]( const Try& try_) const { typedef fusion::vector tuple_type; return try_catch_composite( tuple_type(try_)); } }; try_gen const try_ = try_gen(); }} #if defined(BOOST_MSVC) # pragma warning(pop) #endif #endif