Show
Ignore:
Timestamp:
06/10/08 15:01:26 (5 months ago)
Author:
rjrw
Message:

Remove some superfluous template parameters from the inner workings of
multi_arr.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/container_classes.h

    r1945 r2105  
    3232//! basic_pntr - base class for generalization of normal pointers that enables bounds checking 
    3333//! it comes with the full set of operators that you would expect for a random access pointer 
    34 template<class T, int d, mem_layout ALLOC, bool lgBC> 
     34template<class T, bool lgBC> 
    3535class basic_pntr 
    3636{ 
     
    126126 
    127127//! pntr - interface class to replace normal pointers 
    128 template<class T, int d, mem_layout ALLOC, bool lgBC> 
    129 class pntr : public basic_pntr<T,d,ALLOC,lgBC> 
     128template<class T, bool lgBC> 
     129class pntr : public basic_pntr<T,lgBC> 
    130130{ 
    131131public: 
    132132        // constructors are not inherited, so define them again 
    133         pntr( T* p0 ) : basic_pntr<T,d,ALLOC,lgBC>( p0 ) {} 
    134         pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T,d,ALLOC,lgBC>( p0, p1, p2 ) {} 
     133        pntr( T* p0 ) : basic_pntr<T,lgBC>( p0 ) {} 
     134        pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T,lgBC>( p0, p1, p2 ) {} 
    135135        pntr() {} 
    136136        // the increment / decrement operators need to be recast... 
    137137        // otherwise expressions like p = ++q would be illegal for iterators... 
    138         pntr& operator++ () { return static_cast<pntr&>(basic_pntr<T,d,ALLOC,lgBC>::operator++()); } 
     138        pntr& operator++ () { return static_cast<pntr&>(basic_pntr<T,lgBC>::operator++()); } 
    139139        const pntr operator++ (int) { pntr t = *this; ++(*this); return t; } 
    140         pntr& operator-- () { return static_cast<pntr&>(basic_pntr<T,d,ALLOC,lgBC>::operator--()); } 
     140        pntr& operator-- () { return static_cast<pntr&>(basic_pntr<T,lgBC>::operator--()); } 
    141141        const pntr operator-- (int) { pntr t = *this; --(*this); return t; } 
    142142        // define p+n, p-n, p-q 
     
    147147 
    148148// this defines n+p 
    149 template<class T, int d, mem_layout ALLOC, bool lgBC> 
    150 inline const pntr<T,d,ALLOC,lgBC> operator+ ( const ptrdiff_t n, const pntr<T,d,ALLOC,lgBC>& t ) 
    151 { 
    152         pntr<T,d,ALLOC,lgBC> s = t; 
     149template<class T, bool lgBC> 
     150inline const pntr<T,lgBC> operator+ ( const ptrdiff_t n, const pntr<T,lgBC>& t ) 
     151{ 
     152        pntr<T,lgBC> s = t; 
    153153        s += n; 
    154154        return s; 
     
    156156 
    157157//! const_pntr - same as pntr, except that it replaces const pointers rather than normal pointers 
    158 template<class T, int d, mem_layout ALLOC, bool lgBC> 
    159 class const_pntr : public basic_pntr<T,d,ALLOC,lgBC> 
     158template<class T, bool lgBC> 
     159class const_pntr : public basic_pntr<T,lgBC> 
    160160{ 
    161161public: 
    162162        // constructors are not inherited, so define them again 
    163         const_pntr( T* p0 ) : basic_pntr<T,d,ALLOC,lgBC>( p0 ) {} 
    164         const_pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T,d,ALLOC,lgBC>( p0, p1, p2 ) {} 
     163        const_pntr( T* p0 ) : basic_pntr<T,lgBC>( p0 ) {} 
     164        const_pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T,lgBC>( p0, p1, p2 ) {} 
    165165        const_pntr() {} 
    166166        // make sure we can assign a pntr to a const_pntr by creating an implicit conversion to const_pntr 
    167         const_pntr( const pntr<T,d,ALLOC,lgBC>& t ) : basic_pntr<T,d,ALLOC,lgBC>( t ) {} 
     167        const_pntr( const pntr<T,lgBC>& t ) : basic_pntr<T,lgBC>( t ) {} 
    168168        // the increment / decrement operators need to be recast... 
    169169        // otherwise expressions like *p++ = 1. would be legal for const_iterators... 
    170         const_pntr& operator++ () { return static_cast<const_pntr&>(basic_pntr<T,d,ALLOC,lgBC>::operator++()); } 
     170        const_pntr& operator++ () { return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator++()); } 
    171171        const const_pntr operator++ (int) { const_pntr t = *this; ++(*this); return t; } 
    172         const_pntr& operator-- () { return static_cast<const_pntr&>(basic_pntr<T,d,ALLOC,lgBC>::operator--()); } 
     172        const_pntr& operator-- () { return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator--()); } 
    173173        const const_pntr operator-- (int) { const_pntr t = *this; --(*this); return t; } 
    174174        const_pntr& operator+= ( const ptrdiff_t n ) 
    175175        { 
    176                 return static_cast<const_pntr&>(basic_pntr<T,d,ALLOC,lgBC>::operator+=(n)); 
     176                return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator+=(n)); 
    177177        } 
    178178        const_pntr& operator-= ( const ptrdiff_t n ) 
    179179        { 
    180                 return static_cast<const_pntr&>(basic_pntr<T,d,ALLOC,lgBC>::operator-=(n)); 
     180                return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator-=(n)); 
    181181        } 
    182182        // the dereference operators need to be recast... 
    183         const T& operator* () const { return static_cast<const T&>(basic_pntr<T,d,ALLOC,lgBC>::operator*()); } 
    184         const T* operator-> () const { return static_cast<const T*>(basic_pntr<T,d,ALLOC,lgBC>::operator->()); } 
     183        const T& operator* () const { return static_cast<const T&>(basic_pntr<T,lgBC>::operator*()); } 
     184        const T* operator-> () const { return static_cast<const T*>(basic_pntr<T,lgBC>::operator->()); } 
    185185        const T& operator[] ( const ptrdiff_t n ) const 
    186186        { 
    187                 return static_cast<const T&>(basic_pntr<T,d,ALLOC,lgBC>::operator[](n)); 
     187                return static_cast<const T&>(basic_pntr<T,lgBC>::operator[](n)); 
    188188        } 
    189189        // define p+n, p-n, p-q 
     
    194194 
    195195// this defines n+p 
    196 template<class T, int d, mem_layout ALLOC, bool lgBC> 
    197 inline const const_pntr<T,d,ALLOC,lgBC> operator+ ( const ptrdiff_t n, const const_pntr<T,d,ALLOC,lgBC>& t ) 
    198 { 
    199         const_pntr<T,d,ALLOC,lgBC> s = t; 
     196template<class T, bool lgBC> 
     197inline const const_pntr<T,lgBC> operator+ ( const ptrdiff_t n, const const_pntr<T,lgBC>& t ) 
     198{ 
     199        const_pntr<T,lgBC> s = t; 
    200200        s += n; 
    201201        return s; 
     
    921921        typedef size_t       size_type; 
    922922        typedef ptrdiff_t    difference_type; 
    923         typedef pntr<T,d,ALLOC,lgBC>       iterator; 
    924         typedef const_pntr<T,d,ALLOC,lgBC> const_iterator; 
     923        typedef pntr<T,lgBC>       iterator; 
     924        typedef const_pntr<T,lgBC> const_iterator; 
    925925 
    926926private: 
     
    17191719 
    17201720// on Mac systems these instantiations need to be extern in order to avoid duplicate symbols 
    1721 #define INSTANTIATE_MULTI_ARR( TYPE, LAYOUT, BC ) \ 
    1722 INST_EXTERN template class pntr<TYPE,2,LAYOUT,BC>; \ 
    1723 INST_EXTERN template class pntr<TYPE,3,LAYOUT,BC>; \ 
    1724 INST_EXTERN template class pntr<TYPE,4,LAYOUT,BC>; \ 
    1725 INST_EXTERN template class pntr<TYPE,5,LAYOUT,BC>; \ 
    1726 INST_EXTERN template class pntr<TYPE,6,LAYOUT,BC>; \ 
    1727 INST_EXTERN template class const_pntr<TYPE,2,LAYOUT,BC>; \ 
    1728 INST_EXTERN template class const_pntr<TYPE,3,LAYOUT,BC>; \ 
    1729 INST_EXTERN template class const_pntr<TYPE,4,LAYOUT,BC>; \ 
    1730 INST_EXTERN template class const_pntr<TYPE,5,LAYOUT,BC>; \ 
    1731 INST_EXTERN template class const_pntr<TYPE,6,LAYOUT,BC> 
    1732  
    1733 INSTANTIATE_MULTI_ARR( bool, MEM_LAYOUT_VAL, lgBOUNDSCHECKVAL ); 
    1734 INSTANTIATE_MULTI_ARR( long, MEM_LAYOUT_VAL, lgBOUNDSCHECKVAL ); 
    1735 INSTANTIATE_MULTI_ARR( realnum, MEM_LAYOUT_VAL, lgBOUNDSCHECKVAL ); 
    1736 INSTANTIATE_MULTI_ARR( double, MEM_LAYOUT_VAL, lgBOUNDSCHECKVAL ); 
    1737 INSTANTIATE_MULTI_ARR( double, C_TYPE, lgBOUNDSCHECKVAL ); 
     1721#define INSTANTIATE_MULTI_ARR( TYPE, BC ) \ 
     1722INST_EXTERN template class pntr<TYPE,BC>; \ 
     1723INST_EXTERN template class const_pntr<TYPE,BC>; 
     1724 
     1725INSTANTIATE_MULTI_ARR( bool, lgBOUNDSCHECKVAL ); 
     1726INSTANTIATE_MULTI_ARR( long, lgBOUNDSCHECKVAL ); 
     1727INSTANTIATE_MULTI_ARR( realnum,lgBOUNDSCHECKVAL ); 
     1728INSTANTIATE_MULTI_ARR( double, lgBOUNDSCHECKVAL ); 
    17381729 
    17391730 
     
    17581749        typedef long         size_type; 
    17591750        typedef ptrdiff_t    difference_type; 
    1760         typedef pntr<T,1,FLX_TYPE,lgBC>       iterator; 
    1761         typedef const_pntr<T,1,FLX_TYPE,lgBC> const_iterator; 
     1751        typedef pntr<T,lgBC>       iterator; 
     1752        typedef const_pntr<T,lgBC> const_iterator; 
    17621753 
    17631754private: