comparison DEPENDENCIES/generic/include/boost/iostreams/detail/is_dereferenceable.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
2 // (C) Copyright 2005-2007 Jonathan Turkanis
3 // (C) Copyright David Abrahams 2004.
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
6
7 // See http://www.boost.org/libs/iostreams for documentation.
8
9 #ifndef BOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED
10 #define BOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED
11
12 # include <boost/type_traits/detail/bool_trait_def.hpp>
13 # include <boost/type_traits/detail/template_arity_spec.hpp>
14 # include <boost/type_traits/remove_cv.hpp>
15 # include <boost/mpl/aux_/lambda_support.hpp>
16 # include <boost/mpl/bool.hpp>
17 # include <boost/detail/workaround.hpp>
18
19 namespace boost { namespace iostreams { namespace detail {
20
21 // is_dereferenceable<T> metafunction
22 //
23 // Requires: Given x of type T&, if the expression *x is well-formed
24 // it must have complete type; otherwise, it must neither be ambiguous
25 // nor violate access.
26
27 // This namespace ensures that ADL doesn't mess things up.
28 namespace is_dereferenceable_
29 {
30 // a type returned from operator* when no increment is found in the
31 // type's own namespace
32 struct tag {};
33
34 // any soaks up implicit conversions and makes the following
35 // operator* less-preferred than any other such operator that
36 // might be found via ADL.
37 struct any { template <class T> any(T const&); };
38
39 // This is a last-resort operator* for when none other is found
40 tag operator*(any const&);
41
42 # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) \
43 || BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
44 # define BOOST_comma(a,b) (a)
45 # else
46 // In case an operator++ is found that returns void, we'll use ++x,0
47 tag operator,(tag,int);
48 # define BOOST_comma(a,b) (a,b)
49 # endif
50
51 // two check overloads help us identify which operator++ was picked
52 char (& check_increment(tag) )[2];
53
54 template <class T>
55 char check_increment(T const&);
56
57 template <class T>
58 struct impl
59 {
60 static typename boost::remove_cv<T>::type& x;
61
62 BOOST_STATIC_CONSTANT(
63 bool
64 , value = sizeof(is_dereferenceable_::check_increment(BOOST_comma(*x,0))) == 1
65 );
66 };
67 }
68
69 # undef BOOST_comma
70
71 template<typename T>
72 struct is_dereferenceable
73 BOOST_TT_AUX_BOOL_C_BASE(is_dereferenceable_::impl<T>::value)
74 {
75 BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(is_dereferenceable_::impl<T>::value)
76 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_dereferenceable,(T))
77 };
78
79 } }
80
81 BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::iostreams::detail::is_dereferenceable)
82
83 } // End namespaces detail, iostreams, boost.
84
85 #endif // BOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED