Added traits:

is_incrementable.hpp: checks whether ++x is well-formed

   pointee.hpp: value_type of iterators or smart pointers

   indirect_reference.hpp: reference type of iterators or smart pointers

indirect_iterator.hpp
indirect_iterator_member_types.cpp

   Use pointee/indirect_reference to select value/reference type.

iterator_concepts.hpp: Fixed interoperable test.  Hardly tests enough, but it's a start

minimum_category.hpp: Better error messages for vc6

indirect_iterator_test.cpp: Workarounds for compilers without SFINAE

static_assert_same.hpp: Informative error reports; added a macro.

zip_iterator_test.hpp: Added missing #include

Jamfile: made zip_iterator test pass with vc6/stlport


[SVN r21514]
This commit is contained in:
Dave Abrahams
2004-01-06 17:35:36 +00:00
parent f716d705c5
commit 20b31d1cca
9 changed files with 177 additions and 104 deletions

View File

@ -21,7 +21,13 @@ namespace boost { namespace detail {
//
//
template <bool GreaterEqual, bool LessEqual>
struct minimum_category_impl;
struct minimum_category_impl
# if BOOST_WORKAROUND(BOOST_MSVC, == 1200)
{
typedef void type;
}
# endif
;
template <class T1, class T2>
struct error_not_related_by_convertibility;
@ -58,15 +64,9 @@ template <>
struct minimum_category_impl<false,false>
{
template <class T1, class T2> struct apply
# if BOOST_WORKAROUND(BOOST_MSVC, == 1200)
{
typedef void type;
};
# else
: error_not_related_by_convertibility<T1,T2>
{
};
# endif
};
template <class T1 = mpl::_1, class T2 = mpl::_2>

View File

@ -12,11 +12,15 @@
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/pointee.hpp>
#include <boost/indirect_reference.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/python/detail/indirect_traits.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/apply_if.hpp>
@ -39,43 +43,6 @@ namespace boost
namespace detail
{
template <class T>
struct iterator_is_mutable
: mpl::not_<
boost::python::detail::is_reference_to_const<
typename iterator_reference<T>::type
>
>
{
};
// If the Value parameter is unspecified, we use this metafunction
// to deduce the default type
template <class Dereferenceable>
struct default_indirect_value
{
typedef typename mpl::if_<
iterator_is_mutable<Dereferenceable>
, typename iterator_value<Dereferenceable>::type
, typename iterator_value<Dereferenceable>::type const
>::type type;
};
// If the Reference parameter is unspecified, we use this metafunction
// to deduce the default type
template <class Dereferenceable, class Value>
struct default_indirect_reference
{
struct use_value_ref { typedef Value& type; };
typedef typename
mpl::apply_if<
is_same<Value, use_default>
, iterator_reference<Dereferenceable>
, use_value_ref
>::type type;
};
template <class Iter, class Value, class Category, class Reference, class Difference>
struct indirect_base
{
@ -85,11 +52,16 @@ namespace boost
indirect_iterator<Iter, Value, Category, Reference, Difference>
, Iter
, typename ia_dflt_help<
Value, default_indirect_value<dereferenceable>
Value, pointee<dereferenceable>
>::type
, Category
, typename ia_dflt_help<
Reference, default_indirect_reference<dereferenceable, Value>
Reference
, mpl::apply_if<
is_same<Value,use_default>
, indirect_reference<dereferenceable>
, add_reference<Value>
>
>::type
, Difference
> type;

View File

@ -346,35 +346,50 @@ namespace detail
} // namespace detail
template <typename Iterator, typename ConstIterator>
class InteroperableConcept
{
public:
typedef typename boost::iterator_traversal<Iterator>::type traversal_category;
typedef typename boost::detail::iterator_traits<Iterator>::difference_type
difference_type;
template <typename Iterator, typename ConstIterator>
class InteroperableConcept
{
public:
typedef typename boost::detail::pure_traversal_tag<
typename boost::iterator_traversal<
Iterator
>::type
>::type traversal_category;
typedef typename
boost::detail::iterator_traits<Iterator>::difference_type
difference_type;
typedef typename boost::iterator_traversal<ConstIterator>::type
const_traversal_category;
typedef typename boost::detail::iterator_traits<ConstIterator>::difference_type
const_difference_type;
typedef typename boost::detail::pure_traversal_tag<
typename boost::iterator_traversal<
ConstIterator
>::type
>::type const_traversal_category;
typedef typename
boost::detail::iterator_traits<ConstIterator>::difference_type
const_difference_type;
void constraints() {
BOOST_STATIC_ASSERT((boost::is_same< difference_type,
const_difference_type>::value));
BOOST_STATIC_ASSERT((boost::is_same< traversal_category,
const_traversal_category>::value));
// ToDo check what the std really requires
// detail::Operations<traversal_category>::constraints(i, ci);
void constraints()
{
BOOST_STATIC_ASSERT(
(boost::is_same< difference_type, const_difference_type>::value)
);
BOOST_STATIC_ASSERT(
(boost::is_same< traversal_category, const_traversal_category>::value)
);
ci = i;
// ToDo check what the std really requires
}
Iterator i;
ConstIterator ci;
};
// detail::Operations<traversal_category>::constraints(i, ci);
ci = i;
}
Iterator i;
ConstIterator ci;
};
} // namespace boost_concepts