Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file as_expr.hpp Chris@16: /// Contains definition of the as_expr\<\> and as_child\<\> helper class Chris@16: /// templates used to implement proto::domain's as_expr\<\> and as_child\<\> Chris@16: /// member templates. Chris@16: // Chris@16: // Copyright 2010 Eric Niebler. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_PROTO_DETAIL_AS_EXPR_HPP_EAN_06_09_2010 Chris@16: #define BOOST_PROTO_DETAIL_AS_EXPR_HPP_EAN_06_09_2010 Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@101: #if defined(_MSC_VER) Chris@16: # pragma warning(push) Chris@16: # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined Chris@16: #endif Chris@16: Chris@16: namespace boost { namespace proto { namespace detail Chris@16: { Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct base_generator Chris@16: { Chris@16: typedef Generator type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct base_generator > Chris@16: { Chris@16: typedef Generator type; Chris@16: }; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_expr; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_expr Chris@16: { Chris@16: typedef typename term_traits::value_type value_type; Chris@16: typedef proto::expr, 0> expr_type; Chris@16: typedef typename Generator::template result::type result_type; Chris@16: Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator()(T &t) const Chris@16: { Chris@16: return Generator()(expr_type::make(t)); Chris@16: } Chris@16: }; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_expr Chris@16: { Chris@16: typedef typename term_traits::value_type value_type; Chris@16: typedef proto::basic_expr, 0> expr_type; Chris@16: typedef typename Generator::template result::type result_type; Chris@16: Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator()(T &t) const Chris@16: { Chris@16: return Generator()(expr_type::make(t)); Chris@16: } Chris@16: }; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_expr Chris@16: { Chris@16: typedef typename term_traits::value_type value_type; Chris@16: typedef proto::expr, 0> result_type; Chris@16: Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator()(T &t) const Chris@16: { Chris@16: return result_type::make(t); Chris@16: } Chris@16: }; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_expr Chris@16: { Chris@16: typedef typename term_traits::value_type value_type; Chris@16: typedef proto::basic_expr, 0> result_type; Chris@16: Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator()(T &t) const Chris@16: { Chris@16: return result_type::make(t); Chris@16: } Chris@16: }; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_child; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_child Chris@16: { Chris@16: #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) Chris@16: typedef typename term_traits::reference reference; Chris@16: #else Chris@16: typedef T &reference; Chris@16: #endif Chris@16: typedef proto::expr, 0> expr_type; Chris@16: typedef typename Generator::template result::type result_type; Chris@16: Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator()(T &t) const Chris@16: { Chris@16: return Generator()(expr_type::make(t)); Chris@16: } Chris@16: }; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_child Chris@16: { Chris@16: #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) Chris@16: typedef typename term_traits::reference reference; Chris@16: #else Chris@16: typedef T &reference; Chris@16: #endif Chris@16: typedef proto::basic_expr, 0> expr_type; Chris@16: typedef typename Generator::template result::type result_type; Chris@16: Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator()(T &t) const Chris@16: { Chris@16: return Generator()(expr_type::make(t)); Chris@16: } Chris@16: }; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_child Chris@16: { Chris@16: #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) Chris@16: typedef typename term_traits::reference reference; Chris@16: #else Chris@16: typedef T &reference; Chris@16: #endif Chris@16: typedef proto::expr, 0> result_type; Chris@16: Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator()(T &t) const Chris@16: { Chris@16: return result_type::make(t); Chris@16: } Chris@16: }; Chris@16: Chris@16: //////////////////////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: struct as_child Chris@16: { Chris@16: #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) Chris@16: typedef typename term_traits::reference reference; Chris@16: #else Chris@16: typedef T &reference; Chris@16: #endif Chris@16: typedef proto::basic_expr, 0> result_type; Chris@16: Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator()(T &t) const Chris@16: { Chris@16: return result_type::make(t); Chris@16: } Chris@16: }; Chris@16: Chris@16: }}} Chris@16: Chris@101: #if defined(_MSC_VER) Chris@16: # pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: #endif