Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / iterator / iterator_adaptor.hpp
index 9f2fbb0..87cfd05 100644 (file)
 
 #include <boost/iterator/iterator_traits.hpp>
 
-namespace boost
-{
+namespace boost {
+namespace iterators {
+
   // Used as a default template argument internally, merely to
   // indicate "use the default", this can also be passed by users
   // explicitly in order to specify that the default should be used.
   struct use_default;
-  
-# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
-  // the incompleteness of use_default causes massive problems for
-  // is_convertible (naturally).  This workaround is fortunately not
-  // needed for vc6/vc7.
-  template<class To>
-  struct is_convertible<use_default,To>
-    : mpl::false_ {};
-# endif 
-  
+
+} // namespace iterators
+
+using iterators::use_default;
+
+// the incompleteness of use_default causes massive problems for
+// is_convertible (naturally).  This workaround is fortunately not
+// needed for vc6/vc7.
+template<class To>
+struct is_convertible<use_default,To>
+  : mpl::false_ {};
+
+namespace iterators {
+
   namespace detail
   {
 
-    // 
+    //
     // Result type used in enable_if_convertible meta function.
-    // This can be an incomplete type, as only pointers to 
+    // This can be an incomplete type, as only pointers to
     // enable_if_convertible< ... >::type are used.
     // We could have used void for this, but conversion to
     // void* is just to easy.
@@ -73,7 +78,7 @@ namespace boost
   //   public iterator_adaptor< adapted_iterator<Iterator>, Iterator >
   // {
   // public:
-  //   
+  //
   //   ...
   //
   //   template <class OtherIterator>
@@ -92,38 +97,23 @@ namespace boost
   // and not at the actual instantiation.
   //
   // enable_if_interoperable can be safely used in user code. It falls back to
-  // always enabled for compilers that don't support enable_if or is_convertible. 
-  // There is no need for compiler specific workarounds in user code. 
+  // always enabled for compilers that don't support enable_if or is_convertible.
+  // There is no need for compiler specific workarounds in user code.
   //
   // The operators implementation relies on boost::is_convertible not returning
   // false positives for user/library defined iterator types. See comments
   // on operator implementation for consequences.
   //
-#  if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
-  
-  template<typename From, typename To>
-  struct enable_if_convertible
-  {
-     typedef typename mpl::if_<
-         mpl::or_<
-             is_same<From,To>
-           , is_convertible<From, To>
-         >
-      , boost::detail::enable_type
-      , int&
-     >::type type;
-  };
-  
-#  elif defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_SFINAE)
-  
+#  if defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_SFINAE)
+
   template <class From, class To>
   struct enable_if_convertible
   {
-      typedef boost::detail::enable_type type;
+      typedef boost::iterators::detail::enable_type type;
   };
-  
-#  elif BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292)) && BOOST_MSVC > 1300
-  
+
+#  elif BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292))
+
   // For some reason vc7.1 needs us to "cut off" instantiation
   // of is_convertible in a few cases.
   template<typename From, typename To>
@@ -133,22 +123,22 @@ namespace boost
             is_same<From,To>
           , is_convertible<From, To>
         >
-      , boost::detail::enable_type
+      , boost::iterators::detail::enable_type
     >
   {};
-  
-#  else 
-  
+
+#  else
+
   template<typename From, typename To>
   struct enable_if_convertible
     : iterators::enable_if<
           is_convertible<From, To>
-        , boost::detail::enable_type
+        , boost::iterators::detail::enable_type
       >
   {};
-      
+
 # endif
-  
+
   //
   // Default template argument handling for iterator_adaptor
   //
@@ -180,9 +170,9 @@ namespace boost
     {
         typedef iterator_facade<
             Derived
-            
+
 # ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
-          , typename boost::detail::ia_dflt_help<
+          , typename boost::iterators::detail::ia_dflt_help<
                 Value
               , mpl::eval_if<
                     is_same<Reference,use_default>
@@ -191,17 +181,17 @@ namespace boost
                 >
             >::type
 # else
-          , typename boost::detail::ia_dflt_help<
+          , typename boost::iterators::detail::ia_dflt_help<
                 Value, iterator_value<Base>
             >::type
 # endif
-            
-          , typename boost::detail::ia_dflt_help<
+
+          , typename boost::iterators::detail::ia_dflt_help<
                 Traversal
               , iterator_traversal<Base>
             >::type
 
-          , typename boost::detail::ia_dflt_help<
+          , typename boost::iterators::detail::ia_dflt_help<
                 Reference
               , mpl::eval_if<
                     is_same<Value,use_default>
@@ -210,13 +200,13 @@ namespace boost
                 >
             >::type
 
-          , typename boost::detail::ia_dflt_help<
+          , typename boost::iterators::detail::ia_dflt_help<
                 Difference, iterator_difference<Base>
             >::type
         >
         type;
     };
-  
+
     // workaround for aC++ CR JAGaf33512
     template <class Tr1, class Tr2>
     inline void iterator_adaptor_assert_traversal ()
@@ -224,7 +214,7 @@ namespace boost
       BOOST_STATIC_ASSERT((is_convertible<Tr1, Tr2>::value));
     }
   }
-  
+
   //
   // Iterator Adaptor
   //
@@ -259,14 +249,14 @@ namespace boost
     , class Difference   = use_default
   >
   class iterator_adaptor
-    : public boost::detail::iterator_adaptor_base<
+    : public boost::iterators::detail::iterator_adaptor_base<
         Derived, Base, Value, Traversal, Reference, Difference
       >::type
   {
       friend class iterator_core_access;
 
    protected:
-      typedef typename boost::detail::iterator_adaptor_base<
+      typedef typename boost::iterators::detail::iterator_adaptor_base<
           Derived, Base, Value, Traversal, Reference, Difference
       >::type super_t;
    public:
@@ -285,7 +275,7 @@ namespace boost
    protected:
       // for convenience in derived classes
       typedef iterator_adaptor<Derived,Base,Value,Traversal,Reference,Difference> iterator_adaptor_;
-      
+
       //
       // lvalue access to the Base object for Derived
       //
@@ -301,13 +291,13 @@ namespace boost
       // to prevent temptation for Derived classes to use it, which
       // will often result in an error.  Derived classes should use
       // base_reference(), above, to get direct access to m_iterator.
-      // 
+      //
       typename super_t::reference dereference() const
         { return *m_iterator; }
 
       template <
       class OtherDerived, class OtherIterator, class V, class C, class R, class D
-      >   
+      >
       bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const
       {
         // Maybe readd with same_distance
@@ -322,17 +312,17 @@ namespace boost
       >::type my_traversal;
 
 # define BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(cat) \
-      boost::detail::iterator_adaptor_assert_traversal<my_traversal, cat>();
+      boost::iterators::detail::iterator_adaptor_assert_traversal<my_traversal, cat>();
 
       void advance(typename super_t::difference_type n)
       {
           BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(random_access_traversal_tag)
           m_iterator += n;
       }
-  
+
       void increment() { ++m_iterator; }
 
-      void decrement() 
+      void decrement()
       {
           BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL(bidirectional_traversal_tag)
            --m_iterator;
@@ -340,7 +330,7 @@ namespace boost
 
       template <
           class OtherDerived, class OtherIterator, class V, class C, class R, class D
-      >   
+      >
       typename super_t::difference_type distance_to(
           iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const
       {
@@ -353,11 +343,16 @@ namespace boost
       }
 
 # undef BOOST_ITERATOR_ADAPTOR_ASSERT_TRAVERSAL
-      
+
    private: // data members
       Base m_iterator;
   };
 
+} // namespace iterators
+
+using iterators::iterator_adaptor;
+using iterators::enable_if_convertible;
+
 } // namespace boost
 
 #include <boost/iterator/detail/config_undef.hpp>