Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:00:32

0001 /*=============================================================================
0002     Copyright (c) 2001-2007 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #ifndef BOOST_PHOENIX_CORE_DETAIL_MEMBER_VARIABLE_HPP
0008 #define BOOST_PHOENIX_CORE_DETAIL_MEMBER_VARIABLE_HPP
0009 
0010 #include <boost/proto/detail/decltype.hpp>
0011 #include <boost/type_traits/remove_pointer.hpp>
0012 
0013 #ifdef _MSC_VER
0014 #pragma warning(push)
0015 #pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
0016 #endif
0017 
0018 namespace boost { namespace phoenix { namespace detail {
0019 
0020         template <typename RT, typename MP>
0021         struct member_variable
0022         {
0023             template <typename Sig>
0024             struct result;
0025 
0026             template <typename This, typename Class>
0027             struct result<This(Class)>
0028                 : result<This(Class const &)>
0029             {};
0030 
0031             template <typename This, typename Class>
0032             struct result<This(Class &)>
0033             {
0034                 typedef typename boost::mpl::if_c<
0035                     boost::is_const<
0036                         typename boost::remove_pointer<
0037                             typename boost::remove_reference<Class>::type
0038                         >::type
0039                     >::value
0040                   , const RT&
0041                   , RT&
0042                 >::type
0043                 type;
0044             };
0045 
0046             member_variable(MP mp_)
0047                 : mp(mp_) {}
0048 
0049             template <typename Class>
0050             RT& operator()(Class& obj) const
0051             {
0052                 BOOST_PROTO_USE_GET_POINTER();
0053 
0054                 typedef typename proto::detail::class_member_traits<MP>::class_type class_type;
0055                 return (BOOST_PROTO_GET_POINTER(class_type, obj)->*mp);
0056             }
0057 
0058             template <typename Class>
0059             RT& operator()(Class* obj) const
0060             {
0061                 return obj->*mp;
0062             }
0063 
0064             template <typename Class>
0065             RT const& operator()(Class const& obj) const
0066             {
0067                 BOOST_PROTO_USE_GET_POINTER();
0068 
0069                 typedef typename proto::detail::class_member_traits<MP>::class_type class_type;
0070                 return (BOOST_PROTO_GET_POINTER(class_type, obj)->*mp);
0071             }
0072 
0073             template <typename Class>
0074             RT const& operator()(Class const* obj) const
0075             {
0076                 return obj->*mp;
0077             }
0078 
0079             MP mp;
0080         };
0081 }}}
0082 
0083 #ifdef _MSC_VER
0084 #pragma warning(pop)
0085 #endif
0086 
0087 #endif