diff --git a/include/boost/pointee.hpp b/include/boost/pointee.hpp new file mode 100755 index 0000000..5c40a0f --- /dev/null +++ b/include/boost/pointee.hpp @@ -0,0 +1,40 @@ +// Copyright David Abrahams 2004. Use, modification and distribution is +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef POINTEE_DWA200415_HPP +# define POINTEE_DWA200415_HPP + +// dereferenceable_traits provides access to the value_type and +// reference of a Dereferenceable type. + +# include +# include +# include +# include + +namespace boost { + +namespace detail +{ + template + struct smart_ptr_value + { + typedef typename remove_cv::type type; + }; +} + +template +struct pointee +{ + typedef typename remove_cv

::type stripped; + + typedef typename mpl::apply_if< + detail::is_incrementable + , iterator_value + , detail::smart_ptr_value + >::type type; +}; + +} // namespace boost + +#endif // POINTEE_DWA200415_HPP diff --git a/test/indirect_iterator_member_types.cpp b/test/indirect_iterator_member_types.cpp new file mode 100644 index 0000000..55bff61 --- /dev/null +++ b/test/indirect_iterator_member_types.cpp @@ -0,0 +1,105 @@ +// (C) Copyright Jeremy Siek 2004. Permission to copy, use, modify, +// sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. + +// Revision History +// 03 Jan 2004 Jeremy Siek +// First draft. + + +#include +#include + +#include +#include +#include "static_assert_same.hpp" +#include + +struct zow { }; + +struct my_ptr { + typedef zow const element_type; +// typedef const zow& reference; +// typedef const zow* pointer; +// typedef void difference_type; +// typedef boost::no_traversal_tag iterator_category; +}; + +BOOST_TT_BROKEN_COMPILER_SPEC(my_ptr) +BOOST_TT_BROKEN_COMPILER_SPEC(zow) + +#ifndef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY + +# define STATIC_ASSERT_SAME_POINTER(P1, P2) \ + STATIC_ASSERT_SAME( \ + boost::remove_const::type>::type \ + , boost::remove_const::type>::type \ + ) + +#else + +# define STATIC_ASSERT_SAME_POINTER(P1, P2) STATIC_ASSERT_SAME(P1,P2) + +#endif + +int main() +{ + { + typedef boost::indirect_iterator Iter; + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, int&); + STATIC_ASSERT_SAME_POINTER(Iter::pointer, int*); + STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t); + + BOOST_STATIC_ASSERT((boost::is_convertible::value)); + BOOST_STATIC_ASSERT((boost::is_convertible::type, + boost::random_access_traversal_tag>::value)); + } + { + typedef boost::indirect_iterator Iter; + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, const int&); +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // Borland drops const all over the place + STATIC_ASSERT_SAME_POINTER(Iter::pointer, const int*); +#endif + } + { + typedef boost::indirect_iterator Iter; + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, int&); + STATIC_ASSERT_SAME_POINTER(Iter::pointer, int*); + } + { + typedef boost::indirect_iterator Iter; + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, const int&); +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // Borland drops const all over the place + STATIC_ASSERT_SAME_POINTER(Iter::pointer, const int*); +#endif + } + { + typedef boost::indirect_iterator Iter; + STATIC_ASSERT_SAME(Iter::value_type, zow); +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // Borland drops const all over the place + STATIC_ASSERT_SAME(Iter::reference, const zow&); + STATIC_ASSERT_SAME_POINTER(Iter::pointer, const zow*); +#endif + STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t); + + BOOST_STATIC_ASSERT((boost::is_convertible::value)); + BOOST_STATIC_ASSERT((boost::is_convertible::type, + boost::random_access_traversal_tag>::value)); + } + { + typedef boost::indirect_iterator Iter; + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, long&); + STATIC_ASSERT_SAME_POINTER(Iter::pointer, int*); + STATIC_ASSERT_SAME(Iter::difference_type, short); + } + return 0; +}