OSDN Git Service

indexer_iterator.hpp _indexer_iterator_impl: _ContainerTypeがポインタでない場合は参照になるように(多分)
authorMyun2 <myun2@nwhite.info>
Thu, 3 Jun 2010 07:08:46 +0000 (16:08 +0900)
committerMyun2 <myun2@nwhite.info>
Thu, 3 Jun 2010 07:08:46 +0000 (16:08 +0900)
roast/include/roast/container/indexer_iterator.hpp

index f654deb..12ef943 100644 (file)
@@ -4,11 +4,23 @@
 #define __SFJP_ROAST___container__indexer_iterator_HPP__
 
 #include "roast/container/begin_end_iterator.hpp"
-#include <string.h>
+#include <stdio.h>     //      for NULL
 
 //#define _ROAST_indexer_iterator_DISABLE_IN_WHILE
 
 namespace roast{
+
+       template <typename _ContainerType>
+       struct _indexer_iterator_ContainerMemberType
+       {
+               typedef _ContainerType& type;
+       };
+       template <typename _ContainerType>
+       struct _indexer_iterator_ContainerMemberType<_ContainerType*>
+       {
+               typedef _ContainerType* type;
+       };
+       
        ////////////////////////////////////////////////
        
        template <typename _ContainerType, typename _ValueType, typename _IndexType = size_t >
@@ -20,12 +32,13 @@ namespace roast{
 
        public:
                typedef _ContainerType ContainerType;
+               typedef typename _indexer_iterator_ContainerMemberType<_ContainerType>::type ContainerMemberType;
                typedef _ValueType ValueType;
                typedef _IndexType IndexType;
                typedef _IndexType IteratorType;
                
        protected:
-               _ContainerType m_con;
+               ContainerMemberType m_con;
 
        public:
                //////////////////////////////////////////
@@ -33,13 +46,13 @@ namespace roast{
                //      Constructors
                _indexer_iterator_impl()
                        : _Base(IndexType(0),IndexType(0)),
-                         m_pcon(NULL)
+                         m_con(NULL)
                {}
-               _indexer_iterator_impl(ContainerType con_in, const IndexType& length)
+               _indexer_iterator_impl(const ContainerType& con_in, const IndexType& length)
                        : _Base(IndexType(0),length),
                          m_con(con_in)
                {}
-               _indexer_iterator_impl(ContainerType con_in, const IndexType& start, const IndexType& end)
+               _indexer_iterator_impl(const ContainerType& con_in, const IndexType& start, const IndexType& end)
                        : _Base(start,end),
                          m_con(con_in)
                {}