2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 \brief IteratorTraits public header */
24 #ifndef HH_IteratorTraits_
25 #define HH_IteratorTraits_ 1
31 //#include "IteratorTraits.mpp"
32 ///////////////////////////////hh.p////////////////////////////////////////
36 // The following is *not* standard mandated but it *is* mandated by TR1 and I know of no
37 // implementation for which this is not correct
39 #define SENF_VECTOR_IS_CONTIGUOUS 1
40 #define SENF_STRING_IS_CONTIGUOUS 1
42 /** \brief Check for contiguous mutable storage
44 This type trait returns \c true, if \a RandomAccessIterator is an iterator into a contiguous
45 storage area which may be written to. If this is the case, some algorithms may be optimized
46 by directly modifying the underlying storage instead of relying on the STL interface.
48 This trait is predefined to return \c true for pointers and for the iterators of \c
49 std::vector and \c std::basic_string (and so for \c std::string and \c std::wstring). This
50 is \e not required by the current standard. It is however required for \c std::vector in the
51 first corrigendum to the standard, TR1. Furthermore almost all implementations for \c
52 std::vector do follow this approach.
54 For \c std::string the case is different, there are libraries which use reference counting
55 and shared ownership for strings, however no library with which SENF has been tested to date
56 has strings of this variety. If SENF is used with such a standard library implementation,
57 this header has to be adjysted to define the preprocessor symbol \c
58 SENF_STRING_IS_CONTIGUOUS accordingly.
60 template <class RandomAccessIterator>
61 struct contiguous_storage_iterator
62 : public boost::false_type
66 struct contiguous_storage_iterator<T *>
67 : public boost::true_type
70 #if defined(SENF_VECTOR_IS_CONTIGUOUS)
71 template <class T, class Alloc>
72 struct contiguous_storage_iterator< typename std::vector<T,Alloc>::iterator >
73 : public boost::true_type
77 #if defined(SENF_STRING_IS_CONTIGUOUS)
78 template <class CharT, class Traits, class Alloc>
79 struct contiguous_storage_iterator< typename std::basic_string<CharT, Traits, Alloc>::iterator >
80 : public boost::true_type
84 /** \brief Convert contiguous storage iterator to pointer
86 storage_iterator will convert a contiguous storage iterator into a pointer to the same
87 element in the container. This allows to directly access the containers storage.
89 template <class Iterator>
90 typename std::iterator_traits<Iterator>::pointer storage_iterator(Iterator i);
94 ///////////////////////////////hh.e////////////////////////////////////////
95 //#include "IteratorTraits.cci"
96 //#include "IteratorTraits.ct"
97 //#include "IteratorTraits.cti"
104 // c-file-style: "senf"
105 // indent-tabs-mode: nil
106 // ispell-local-dictionary: "american"