fixes and cleanups

[SVN r1141]
This commit is contained in:
Dave Abrahams
2003-04-10 13:40:42 +00:00
parent c1e5d7e331
commit aa0a32aa33
13 changed files with 218 additions and 137 deletions
+6 -7
View File
@@ -8,21 +8,22 @@
#define BOOST_ITERATOR_DETAIL_CATEGORIES_HPP
#include <boost/config.hpp>
#include <boost/iterator/detail/config_def.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/apply_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/and.hpp>
#include <iterator>
#if BOOST_WORKAROUND(__MWERKS__, <=0x2407)
# define BOOST_NO_IS_CONVERTIBLE // "Convertible does not provide enough/is not working"
#endif
#include <iterator>
namespace boost
{
@@ -296,8 +297,6 @@ namespace boost
} // namespace boost
#ifdef BOOST_NO_IS_CONVERTIBLE
# undef BOOST_NO_IS_CONVERTIBLE
#endif
#include <boost/iterator/detail/config_undef.hpp>
#endif // BOOST_ITERATOR_DETAIL_CATEGORIES_HPP
+63 -8
View File
@@ -18,26 +18,81 @@
#include <boost/config.hpp> // for prior
#include <boost/detail/workaround.hpp>
#define BOOST_ITERATOR_CONFIG_DEF // if you get an error here, you have nested config_def #inclusion.
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|| BOOST_WORKAROUND(__GNUC__, <= 2 && __GNUC_MINOR__ <= 95) \
|| BOOST_WORKAROUND(__MWERKS__, <= 0x3000)
|| BOOST_WORKAROUND(__MWERKS__, <= 0x3000) \
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
# define BOOST_NO_SFINAE // "Substitution Failure Is Not An Error not implemented"
#endif
#if BOOST_WORKAROUND(BOOST_MSVC, <=1200)
# define BOOST_ARG_DEP_TYPENAME
#else
# define BOOST_ARG_DEP_TYPENAME typename
# if 0 // test code
template <bool x>
struct bar
{
typedef int type;
};
template <>
struct bar<false>
{
};
template <class T>
struct foo : bar<(sizeof(T) == 1)>
{
};
template <class T>
char* f(int, typename foo<T>::type = 0) { return 0; }
template <class T>
int f(...) { return 0; }
char* x = f<char>(0);
int y = f<char[2]>(0);
int main()
{
return 0;
}
# endif
#endif
#if BOOST_WORKAROUND(__MWERKS__, <=0x2407)
# define BOOST_NO_IS_CONVERTIBLE // "is_convertible doesn't always work"
# define BOOST_NO_IS_CONVERTIBLE // "is_convertible doesn't work for simple types"
#endif
#if BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(3)) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
# define BOOST_NO_IS_CONVERTIBLE_TEMPLATE // The following program fails to compile:
# if 0 // test code
template <class T>
struct foo
{
foo(T);
template <class U>
foo(foo<U> const& other) : p(other.p) { }
T p;
};
bool x = boost::is_convertible<foo<int const*>, foo<int*> >::value;
# endif
#endif
#if BOOST_WORKAROUND(__GNUC__, == 2 && __GNUC_MINOR__ == 95) \
|| BOOST_WORKAROUND(__MWERKS__, <= 0x2407) \
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
# define BOOST_NO_MPL_AUX_HAS_XXX // "MPL's has_xxx facility doesn't work"
# define BOOST_ITERATOR_NO_MPL_AUX_HAS_XXX // "MPL's has_xxx facility doesn't work"
#endif
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_IS_CONVERTIBLE_TEMPLATE)
# define BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
#endif
// no include guard multiple inclusion intended
@@ -13,8 +13,13 @@
// 23/02/03 thw
//
# undef BOOST_NO_SFINAE
# undef BOOST_ARG_DEP_TYPENAME
# undef BOOST_NO_IS_CONVERTIBLE
# undef BOOST_NO_MPL_AUX_HAS_XXX
#undef BOOST_NO_SFINAE
#undef BOOST_NO_IS_CONVERTIBLE
#undef BOOST_NO_IS_CONVERTIBLE_TEMPLATE
#undef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
#ifdef BOOST_ITERATOR_CONFIG_DEF
# undef BOOST_ITERATOR_CONFIG_DEF
#else
# error missing or nested #include config_def
#endif
+37 -42
View File
@@ -12,11 +12,11 @@
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/detail/config_def.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/python/detail/indirect_traits.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/aux_/has_xxx.hpp>
#ifdef BOOST_NO_MPL_AUX_HAS_XXX
# include <boost/shared_ptr.hpp>
@@ -25,6 +25,8 @@
# include <memory>
#endif
#include <boost/iterator/detail/config_def.hpp> // must be last #include
namespace boost
{
template <class Iter, class Value, class Category, class Reference, class Pointer, class Difference>
@@ -42,7 +44,7 @@ namespace boost
// can be used instead with something like
// boost/python/pointee.hpp to find the value_type.
//
# if !defined BOOST_NO_MPL_AUX_HAS_XXX
# ifndef BOOST_NO_MPL_AUX_HAS_XXX
namespace aux
{
BOOST_MPL_HAS_XXX_TRAIT_DEF(element_type)
@@ -136,13 +138,13 @@ namespace boost
>::type cv_value_type;
typedef iterator_adaptor<
indirect_iterator<Iter, Value, Category, Reference, Pointer, Difference>
, Iter
, cv_value_type
, Category
, Reference
, Pointer
, Difference
indirect_iterator<Iter, Value, Category, Reference, Pointer, Difference>
, Iter
, cv_value_type
, Category
, Reference
, Pointer
, Difference
> type;
};
@@ -152,48 +154,42 @@ namespace boost
template <
class Iterator
, class Value = not_specified
, class Category = not_specified
, class Reference = not_specified
, class Pointer = not_specified
, class Difference = not_specified
, class Value = not_specified
, class Category = not_specified
, class Reference = not_specified
, class Pointer = not_specified
, class Difference = not_specified
>
class indirect_iterator
: public detail::indirect_base<
Iterator
, Value
, Category
, Reference
, Pointer
, Difference
Iterator, Value, Category, Reference, Pointer, Difference
>::type
{
typedef typename detail::indirect_base<
Iterator
, Value
, Category
, Reference
, Pointer
, Difference
>::type super_t;
typedef typename detail::indirect_base<
Iterator, Value, Category, Reference, Pointer, Difference
>::type super_t;
friend class iterator_core_access;
friend class iterator_core_access;
public:
indirect_iterator() {}
public:
indirect_iterator() {}
indirect_iterator(Iterator iter)
: super_t(iter) {}
indirect_iterator(Iterator iter)
: super_t(iter) {}
template <class OtherIterator,
class OtherTraits>
indirect_iterator(
indirect_iterator<OtherIterator, OtherTraits> const& y
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0
)
: super_t(y.base())
template <
class Iterator2, class Value2, class Category2
, class Reference2, class Pointer2, class Difference2
>
indirect_iterator(
indirect_iterator<
Iterator2, Value2, Category2, Reference2, Pointer2, Difference2
> const& y
, typename enable_if_convertible<Iterator2, Iterator>::type* = 0
)
: super_t(y.base())
{}
private:
typename super_t::reference dereference() const
{
@@ -203,7 +199,6 @@ namespace boost
return **this->base();
# endif
}
};
template <class Iter>
+9 -9
View File
@@ -7,14 +7,14 @@
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef BOOST_INTEROPERABLE_23022003THW_HPP
#define BOOST_INTEROPERABLE_23022003THW_HPP
# define BOOST_INTEROPERABLE_23022003THW_HPP
#include <boost/mpl/bool.hpp>
#include <boost/mpl/or.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/mpl/or.hpp>
#include <boost/type_traits/is_convertible.hpp>
# include <boost/type_traits/is_convertible.hpp>
#include <boost/iterator/detail/config_def.hpp>
# include <boost/iterator/detail/config_def.hpp> // must appear last
namespace boost
{
@@ -35,18 +35,18 @@ namespace boost
//
template <typename A, typename B>
struct is_interoperable
#if defined(BOOST_NO_IS_CONVERTIBLE)
# ifdef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
: mpl::true_
#else
# else
: mpl::or_<
is_convertible< A, B >
, is_convertible< B, A > >
#endif
# endif
{
};
} // namespace boost
#include <boost/iterator/detail/config_undef.hpp>
# include <boost/iterator/detail/config_undef.hpp>
#endif // BOOST_INTEROPERABLE_23022003THW_HPP
+33 -22
View File
@@ -97,29 +97,40 @@ namespace boost
// false positives for user/library defined iterator types. See comments
// on operator implementation for consequences.
//
template<
typename From
, typename To>
# if defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_SFINAE)
template <class From, class To>
struct enable_if_convertible
{
// Borland 551 and vc6 have a problem with the use of base class
// forwarding in this template, so we write it all out here
# if defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_SFINAE)
typedef detail::enable_type type;
# else
typedef typename detail::enable_if<
# if BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292) && BOOST_MSVC > 1300)
// For some reason vc7.1 needs us to "cut off" instantiation
// of is_convertible in the case where From == To.
mpl::or_<is_same<From,To>, is_convertible<From, To> >
# else
::boost::is_convertible<From, To>
# endif
, detail::enable_type
>::type type;
# endif
};
# elif BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292)) && BOOST_MSVC > 1300
// For some reason vc7.1 needs us to "cut off" instantiation
// of is_convertible in a few cases.
template<typename From, typename To>
struct enable_if_convertible
: detail::enable_if<
mpl::or_<
is_same<From,To>
, is_convertible<From, To>
>
, detail::enable_type
>
{};
# else
template<typename From, typename To>
struct enable_if_convertible
: detail::enable_if<
is_convertible<From, To>
, detail::enable_type
>
{};
# endif
//
// iterator_traits_adaptor can be used to create new iterator traits by adapting
@@ -201,9 +212,9 @@ namespace boost
class Derived
, class Base
, class Value = not_specified
, class Category = not_specified
, class Reference = not_specified
, class Pointer = not_specified
, class Category = not_specified
, class Reference = not_specified
, class Pointer = not_specified
, class Difference = not_specified
>
class iterator_adaptor
+13 -6
View File
@@ -20,9 +20,11 @@
#include <boost/type_traits/is_convertible.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/detail/config_def.hpp>
#include <boost/mpl/apply_if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/iterator/detail/config_def.hpp> // this goes last
namespace boost
{
@@ -44,14 +46,19 @@ namespace boost
, class Return
>
struct enable_if_interoperable
#ifndef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
: ::boost::detail::enable_if<
is_convertible<Facade1, Facade2>
mpl::or_<
is_convertible<Facade1, Facade2>
, is_convertible<Facade2, Facade1>
>
, Return
>
#endif
{
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
#ifdef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
typedef Return type;
# endif
#endif
};
@@ -483,8 +490,8 @@ namespace boost
-
, typename Derived1::difference_type
, (is_same<
BOOST_ARG_DEP_TYPENAME Derived1::difference_type
, BOOST_ARG_DEP_TYPENAME Derived2::difference_type
BOOST_DEDUCED_TYPENAME Derived1::difference_type
, BOOST_DEDUCED_TYPENAME Derived2::difference_type
>::value)
, return
, distance_to )
@@ -45,8 +45,8 @@ void readable_iterator_test(const Iterator i1, T v)
T v2 = r2;
assert(v1 == v);
assert(v2 == v);
typename access_category<Iterator>::type result_category;
is_readable(result_category);
typedef typename access_category<Iterator>::type result_category;
is_readable(result_category());
}
template <class Iterator, class T>
+4 -3
View File
@@ -36,9 +36,10 @@ namespace boost
template<class OtherIterator>
reverse_iterator(
reverse_iterator<OtherIterator> const& r
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0
)
: super_t(r.base()) {}
, typename enable_if_convertible<OtherIterator, Iterator>::type* = 0
)
: super_t(r.base())
{}
private:
typename super_t::reference dereference() const { return *boost::prior(this->base()); }