Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:44:35

0001 // Copyright David Abrahams 2003. Use, modification and distribution is
0002 // subject to the Boost Software License, Version 1.0. (See accompanying
0003 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0004 #ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP
0005 # define IS_LVALUE_ITERATOR_DWA2003112_HPP
0006 
0007 #include <boost/detail/workaround.hpp>
0008 
0009 #include <boost/type_traits/add_lvalue_reference.hpp>
0010 #include <boost/iterator/detail/any_conversion_eater.hpp>
0011 #include <boost/mpl/bool.hpp>
0012 #include <boost/mpl/aux_/lambda_support.hpp>
0013 
0014 #include <iterator>
0015 
0016 // should be the last #includes
0017 #include <boost/type_traits/integral_constant.hpp>
0018 #include <boost/iterator/detail/config_def.hpp>
0019 
0020 #ifndef BOOST_NO_IS_CONVERTIBLE
0021 
0022 namespace boost {
0023 
0024 namespace iterators {
0025 
0026 namespace detail
0027 {
0028 #ifndef BOOST_NO_LVALUE_RETURN_DETECTION
0029   // Calling lvalue_preserver( <expression>, 0 ) returns a reference
0030   // to the expression's result if <expression> is an lvalue, or
0031   // not_an_lvalue() otherwise.
0032   struct not_an_lvalue {};
0033 
0034   template <class T>
0035   T& lvalue_preserver(T&, int);
0036 
0037   template <class U>
0038   not_an_lvalue lvalue_preserver(U const&, ...);
0039 
0040 # define BOOST_LVALUE_PRESERVER(expr) detail::lvalue_preserver(expr,0)
0041 
0042 #else
0043 
0044 # define BOOST_LVALUE_PRESERVER(expr) expr
0045 
0046 #endif
0047 
0048   // Guts of is_lvalue_iterator.  Value is the iterator's value_type
0049   // and the result is computed in the nested rebind template.
0050   template <class Value>
0051   struct is_lvalue_iterator_impl
0052   {
0053       // Eat implicit conversions so we don't report true for things
0054       // convertible to Value const&
0055       struct conversion_eater
0056       {
0057           conversion_eater(typename add_lvalue_reference<Value>::type);
0058       };
0059 
0060       static char tester(conversion_eater, int);
0061       static char (& tester(any_conversion_eater, ...) )[2];
0062 
0063       template <class It>
0064       struct rebind
0065       {
0066           static It& x;
0067 
0068           BOOST_STATIC_CONSTANT(
0069               bool
0070             , value = (
0071                 sizeof(
0072                     is_lvalue_iterator_impl<Value>::tester(
0073                         BOOST_LVALUE_PRESERVER(*x), 0
0074                     )
0075                 ) == 1
0076             )
0077           );
0078       };
0079   };
0080 
0081 #undef BOOST_LVALUE_PRESERVER
0082 
0083   //
0084   // void specializations to handle std input and output iterators
0085   //
0086   template <>
0087   struct is_lvalue_iterator_impl<void>
0088   {
0089       template <class It>
0090       struct rebind : boost::mpl::false_
0091       {};
0092   };
0093 
0094 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
0095   template <>
0096   struct is_lvalue_iterator_impl<const void>
0097   {
0098       template <class It>
0099       struct rebind : boost::mpl::false_
0100       {};
0101   };
0102 
0103   template <>
0104   struct is_lvalue_iterator_impl<volatile void>
0105   {
0106       template <class It>
0107       struct rebind : boost::mpl::false_
0108       {};
0109   };
0110 
0111   template <>
0112   struct is_lvalue_iterator_impl<const volatile void>
0113   {
0114       template <class It>
0115       struct rebind : boost::mpl::false_
0116       {};
0117   };
0118 #endif
0119 
0120   //
0121   // This level of dispatching is required for Borland.  We might save
0122   // an instantiation by removing it for others.
0123   //
0124   template <class It>
0125   struct is_readable_lvalue_iterator_impl
0126     : is_lvalue_iterator_impl<
0127           BOOST_DEDUCED_TYPENAME std::iterator_traits<It>::value_type const
0128       >::template rebind<It>
0129   {};
0130 
0131   template <class It>
0132   struct is_non_const_lvalue_iterator_impl
0133     : is_lvalue_iterator_impl<
0134           BOOST_DEDUCED_TYPENAME std::iterator_traits<It>::value_type
0135       >::template rebind<It>
0136   {};
0137 } // namespace detail
0138 
0139 template< typename T > struct is_lvalue_iterator
0140 : public ::boost::integral_constant<bool,::boost::iterators::detail::is_readable_lvalue_iterator_impl<T>::value>
0141 {
0142 public:
0143     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_lvalue_iterator,(T))
0144 };
0145 
0146 template< typename T > struct is_non_const_lvalue_iterator
0147 : public ::boost::integral_constant<bool,::boost::iterators::detail::is_non_const_lvalue_iterator_impl<T>::value>
0148 {
0149 public:
0150     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_non_const_lvalue_iterator,(T))
0151 };
0152 
0153 } // namespace iterators
0154 
0155 using iterators::is_lvalue_iterator;
0156 using iterators::is_non_const_lvalue_iterator;
0157 
0158 } // namespace boost
0159 
0160 #endif
0161 
0162 #include <boost/iterator/detail/config_undef.hpp>
0163 
0164 #endif // IS_LVALUE_ITERATOR_DWA2003112_HPP