Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:50

0001 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
0002 // (C) Copyright 2005-2007 Jonathan Turkanis
0003 // (C) Copyright David Abrahams 2004.
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 // See http://www.boost.org/libs/iostreams for documentation.
0008 
0009 #ifndef BOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED
0010 #define BOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED
0011 
0012 # include <boost/type_traits/remove_cv.hpp>
0013 # include <boost/mpl/aux_/lambda_support.hpp>
0014 # include <boost/mpl/bool.hpp>
0015 # include <boost/detail/workaround.hpp>
0016 
0017 namespace boost { namespace iostreams { namespace detail { 
0018 
0019 // is_dereferenceable<T> metafunction
0020 //
0021 // Requires: Given x of type T&, if the expression *x is well-formed
0022 // it must have complete type; otherwise, it must neither be ambiguous
0023 // nor violate access.
0024 
0025 // This namespace ensures that ADL doesn't mess things up.
0026 namespace is_dereferenceable_
0027 {
0028   // a type returned from operator* when no increment is found in the
0029   // type's own namespace
0030   struct tag {};
0031   
0032   // any soaks up implicit conversions and makes the following
0033   // operator* less-preferred than any other such operator that
0034   // might be found via ADL.
0035   struct any { template <class T> any(T const&); };
0036 
0037   // This is a last-resort operator* for when none other is found
0038   tag operator*(any const&);
0039 
0040 # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202))
0041 #  define BOOST_comma(a,b) (a)
0042 # else 
0043   // In case an operator++ is found that returns void, we'll use ++x,0
0044   tag operator,(tag,int);  
0045 #  define BOOST_comma(a,b) (a,b)
0046 # endif 
0047   
0048   // two check overloads help us identify which operator++ was picked
0049   char (& check_increment(tag) )[2];
0050   
0051   template <class T>
0052   char check_increment(T const&);
0053   
0054   template <class T>
0055   struct impl
0056   {
0057       static typename boost::remove_cv<T>::type& x;
0058 
0059       BOOST_STATIC_CONSTANT(
0060           bool
0061         , value = sizeof(is_dereferenceable_::check_increment(BOOST_comma(*x,0))) == 1
0062       );
0063   };
0064 }
0065 
0066 # undef BOOST_comma
0067 
0068 template<typename T> 
0069 struct is_dereferenceable 
0070     : public ::boost::integral_constant<bool, is_dereferenceable_::impl<T>::value >
0071 { 
0072     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_dereferenceable,(T))
0073 };
0074 
0075 } } 
0076 
0077 
0078 } // End namespaces detail, iostreams, boost.
0079 
0080 #endif // BOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED