Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:58:27

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file expr.hpp
0003 /// Contains definition of expr\<\> class template.
0004 //
0005 //  Copyright 2008 Eric Niebler. Distributed under the Boost
0006 //  Software License, Version 1.0. (See accompanying file
0007 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #ifndef BOOST_PROTO_EXPR_HPP_EAN_04_01_2005
0010 #define BOOST_PROTO_EXPR_HPP_EAN_04_01_2005
0011 
0012 #include <boost/preprocessor/cat.hpp>
0013 #include <boost/preprocessor/arithmetic/dec.hpp>
0014 #include <boost/preprocessor/selection/max.hpp>
0015 #include <boost/preprocessor/iteration/iterate.hpp>
0016 #include <boost/preprocessor/facilities/intercept.hpp>
0017 #include <boost/preprocessor/repetition/repeat.hpp>
0018 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
0019 #include <boost/preprocessor/repetition/enum_trailing.hpp>
0020 #include <boost/preprocessor/repetition/enum_params.hpp>
0021 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
0022 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
0023 #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
0024 #include <boost/utility/addressof.hpp>
0025 #include <boost/proto/proto_fwd.hpp>
0026 #include <boost/proto/args.hpp>
0027 #include <boost/proto/traits.hpp>
0028 
0029 #if defined(_MSC_VER)
0030 # pragma warning(push)
0031 # pragma warning(disable : 4510) // default constructor could not be generated
0032 # pragma warning(disable : 4512) // assignment operator could not be generated
0033 # pragma warning(disable : 4610) // user defined constructor required
0034 # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined
0035 #endif
0036 
0037 namespace boost { namespace proto
0038 {
0039 
0040     namespace detail
0041     {
0042         struct not_a_valid_type
0043         {
0044         private:
0045             not_a_valid_type()
0046             {}
0047         };
0048         
0049         template<typename Tag, typename Arg>
0050         struct address_of_hack
0051         {
0052             typedef not_a_valid_type type;
0053         };
0054 
0055         template<typename Expr>
0056         struct address_of_hack<proto::tag::address_of, Expr &>
0057         {
0058             typedef Expr *type;
0059         };
0060 
0061         template<typename T, typename Expr, typename Arg0>
0062         BOOST_FORCEINLINE
0063         Expr make_terminal(T &t, Expr *, proto::term<Arg0> *)
0064         {
0065             Expr that = {t};
0066             return that;
0067         }
0068 
0069         template<typename T, typename Expr, typename Arg0, std::size_t N>
0070         BOOST_FORCEINLINE
0071         Expr make_terminal(T (&t)[N], Expr *, proto::term<Arg0[N]> *)
0072         {
0073             Expr that;
0074             for(std::size_t i = 0; i < N; ++i)
0075             {
0076                 that.child0[i] = t[i];
0077             }
0078             return that;
0079         }
0080 
0081         template<typename T, typename Expr, typename Arg0, std::size_t N>
0082         BOOST_FORCEINLINE
0083         Expr make_terminal(T const(&t)[N], Expr *, proto::term<Arg0[N]> *)
0084         {
0085             Expr that;
0086             for(std::size_t i = 0; i < N; ++i)
0087             {
0088                 that.child0[i] = t[i];
0089             }
0090             return that;
0091         }
0092 
0093         // Work-around for:
0094         // https://connect.microsoft.com/VisualStudio/feedback/details/765449/codegen-stack-corruption-using-runtime-checks-when-aggregate-initializing-struct
0095     #if BOOST_WORKAROUND(BOOST_MSVC, < 1800)
0096         template<typename T, typename Expr, typename C, typename U>
0097         BOOST_FORCEINLINE
0098         Expr make_terminal(T &t, Expr *, proto::term<U C::*> *)
0099         {
0100             Expr that;
0101             that.child0 = t;
0102             return that;
0103         }
0104     #endif
0105 
0106         template<typename T, typename U>
0107         struct same_cv
0108         {
0109             typedef U type;
0110         };
0111 
0112         template<typename T, typename U>
0113         struct same_cv<T const, U>
0114         {
0115             typedef U const type;
0116         };
0117     }
0118 
0119     namespace result_of
0120     {
0121         /// \brief A helper metafunction for computing the
0122         /// return type of \c proto::expr\<\>::operator().
0123         template<typename Sig, typename This, typename Domain>
0124         struct funop;
0125 
0126         #include <boost/proto/detail/funop.hpp>
0127     }
0128 
0129     namespace exprns_
0130     {
0131         // This is where the basic_expr specializations are
0132         // actually defined:
0133         #include <boost/proto/detail/basic_expr.hpp>
0134 
0135         #if defined(__GNUC__) && __GNUC__ >= 9 || defined(__clang__) && __clang_major__ >= 10
0136             #pragma GCC diagnostic push
0137             // The warning cannot be fixed for aggregates
0138             // Sadly, GCC currently emits the warning at the use location:
0139             // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94492
0140             #pragma GCC diagnostic ignored "-Wdeprecated-copy"
0141         #endif
0142 
0143         // This is where the expr specialization are
0144         // actually defined:
0145         #include <boost/proto/detail/expr.hpp>
0146 
0147         #if defined(__GNUC__) && __GNUC__ >= 9 || defined(__clang__) && __clang_major__ >= 10
0148             #pragma GCC diagnostic pop
0149         #endif
0150     }
0151 
0152     /// \brief Lets you inherit the interface of an expression
0153     /// while hiding from Proto the fact that the type is a Proto
0154     /// expression.
0155     template<typename Expr>
0156     struct unexpr
0157       : Expr
0158     {
0159         BOOST_PROTO_UNEXPR()
0160 
0161         BOOST_FORCEINLINE
0162         explicit unexpr(Expr const &e)
0163           : Expr(e)
0164         {}
0165         
0166         using Expr::operator =;
0167     };
0168 
0169 }}
0170 
0171 #if defined(_MSC_VER)
0172 # pragma warning(pop)
0173 #endif
0174 
0175 #endif // BOOST_PROTO_EXPR_HPP_EAN_04_01_2005