Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file expr.hpp Chris@16: /// Contains definition of expr\<\> class template. Chris@16: // Chris@16: // Copyright 2008 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_EXPR_HPP_EAN_04_01_2005 Chris@16: #define BOOST_PROTO_EXPR_HPP_EAN_04_01_2005 Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include 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 : 4510) // default constructor could not be generated Chris@16: # pragma warning(disable : 4512) // assignment operator could not be generated Chris@16: # pragma warning(disable : 4610) // user defined constructor required Chris@16: # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined Chris@16: #endif Chris@16: Chris@16: namespace boost { namespace proto Chris@16: { Chris@16: Chris@16: namespace detail Chris@16: { Chris@16: struct not_a_valid_type Chris@16: { Chris@16: private: Chris@16: not_a_valid_type() Chris@16: {} Chris@16: }; Chris@16: Chris@16: template Chris@16: struct address_of_hack Chris@16: { Chris@16: typedef not_a_valid_type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct address_of_hack Chris@16: { Chris@16: typedef Expr *type; Chris@16: }; Chris@16: Chris@16: template Chris@16: BOOST_FORCEINLINE Chris@16: Expr make_terminal(T &t, Expr *, proto::term *) Chris@16: { Chris@16: Expr that = {t}; Chris@16: return that; Chris@16: } Chris@16: Chris@16: template Chris@16: BOOST_FORCEINLINE Chris@16: Expr make_terminal(T (&t)[N], Expr *, proto::term *) Chris@16: { Chris@16: Expr that; Chris@16: for(std::size_t i = 0; i < N; ++i) Chris@16: { Chris@16: that.child0[i] = t[i]; Chris@16: } Chris@16: return that; Chris@16: } Chris@16: Chris@16: template Chris@16: BOOST_FORCEINLINE Chris@16: Expr make_terminal(T const(&t)[N], Expr *, proto::term *) Chris@16: { Chris@16: Expr that; Chris@16: for(std::size_t i = 0; i < N; ++i) Chris@16: { Chris@16: that.child0[i] = t[i]; Chris@16: } Chris@16: return that; Chris@16: } Chris@16: Chris@16: // Work-around for: Chris@16: // https://connect.microsoft.com/VisualStudio/feedback/details/765449/codegen-stack-corruption-using-runtime-checks-when-aggregate-initializing-struct Chris@16: #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1700)) Chris@16: template Chris@16: BOOST_FORCEINLINE Chris@16: Expr make_terminal(T &t, Expr *, proto::term *) Chris@16: { Chris@16: Expr that; Chris@16: that.child0 = t; Chris@16: return that; Chris@16: } Chris@16: #endif Chris@16: Chris@16: template Chris@16: struct same_cv Chris@16: { Chris@16: typedef U type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct same_cv Chris@16: { Chris@16: typedef U const type; Chris@16: }; Chris@16: } Chris@16: Chris@16: namespace result_of Chris@16: { Chris@16: /// \brief A helper metafunction for computing the Chris@16: /// return type of \c proto::expr\<\>::operator(). Chris@16: template Chris@16: struct funop; Chris@16: Chris@16: #include Chris@16: } Chris@16: Chris@16: namespace exprns_ Chris@16: { Chris@16: // This is where the basic_expr specializations are Chris@16: // actually defined: Chris@16: #include Chris@16: Chris@16: // This is where the expr specialization are Chris@16: // actually defined: Chris@16: #include Chris@16: } Chris@16: Chris@16: /// \brief Lets you inherit the interface of an expression Chris@16: /// while hiding from Proto the fact that the type is a Proto Chris@16: /// expression. Chris@16: template Chris@16: struct unexpr Chris@16: : Expr Chris@16: { Chris@16: BOOST_PROTO_UNEXPR() Chris@16: Chris@16: BOOST_FORCEINLINE Chris@16: explicit unexpr(Expr const &e) Chris@16: : Expr(e) Chris@16: {} Chris@16: Chris@16: using Expr::operator =; 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 // BOOST_PROTO_EXPR_HPP_EAN_04_01_2005