| 1 | // Boost string_algo library sequence_traits.hpp header file ---------------------------// |
| 2 | |
| 3 | // Copyright Pavol Droba 2002-2003. |
| 4 | // |
| 5 | // Distributed under the Boost Software License, Version 1.0. |
| 6 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
| 8 | |
| 9 | // See http://www.boost.org/ for updates, documentation, and revision history. |
| 10 | |
| 11 | #ifndef BOOST_STRING_SEQUENCE_TRAITS_HPP |
| 12 | #define BOOST_STRING_SEQUENCE_TRAITS_HPP |
| 13 | |
| 14 | #include <boost/config.hpp> |
| 15 | #include <boost/mpl/bool.hpp> |
| 16 | #include <boost/algorithm/string/yes_no_type.hpp> |
| 17 | |
| 18 | /*! \file |
| 19 | Traits defined in this header are used by various algorithms to achieve |
| 20 | better performance for specific containers. |
| 21 | Traits provide fail-safe defaults. If a container supports some of these |
| 22 | features, it is possible to specialize the specific trait for this container. |
| 23 | For lacking compilers, it is possible of define an override for a specific tester |
| 24 | function. |
| 25 | |
| 26 | Due to a language restriction, it is not currently possible to define specializations for |
| 27 | stl containers without including the corresponding header. To decrease the overhead |
| 28 | needed by this inclusion, user can selectively include a specialization |
| 29 | header for a specific container. They are located in boost/algorithm/string/stl |
| 30 | directory. Alternatively she can include boost/algorithm/string/std_collection_traits.hpp |
| 31 | header which contains specializations for all stl containers. |
| 32 | */ |
| 33 | |
| 34 | namespace boost { |
| 35 | namespace algorithm { |
| 36 | |
| 37 | // sequence traits -----------------------------------------------// |
| 38 | |
| 39 | |
| 40 | //! Native replace trait |
| 41 | /*! |
| 42 | This trait specifies that the sequence has \c std::string like replace method |
| 43 | */ |
| 44 | template< typename T > |
| 45 | class has_native_replace |
| 46 | { |
| 47 | |
| 48 | public: |
| 49 | # if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) |
| 50 | enum { value = false }; |
| 51 | # else |
| 52 | BOOST_STATIC_CONSTANT(bool, value=false); |
| 53 | # endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) |
| 54 | |
| 55 | |
| 56 | typedef mpl::bool_<has_native_replace<T>::value> type; |
| 57 | }; |
| 58 | |
| 59 | |
| 60 | //! Stable iterators trait |
| 61 | /*! |
| 62 | This trait specifies that the sequence has stable iterators. It means |
| 63 | that operations like insert/erase/replace do not invalidate iterators. |
| 64 | */ |
| 65 | template< typename T > |
| 66 | class has_stable_iterators |
| 67 | { |
| 68 | public: |
| 69 | # if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) |
| 70 | enum { value = false }; |
| 71 | # else |
| 72 | BOOST_STATIC_CONSTANT(bool, value=false); |
| 73 | # endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) |
| 74 | |
| 75 | typedef mpl::bool_<has_stable_iterators<T>::value> type; |
| 76 | }; |
| 77 | |
| 78 | |
| 79 | //! Const time insert trait |
| 80 | /*! |
| 81 | This trait specifies that the sequence's insert method has |
| 82 | constant time complexity. |
| 83 | */ |
| 84 | template< typename T > |
| 85 | class has_const_time_insert |
| 86 | { |
| 87 | public: |
| 88 | # if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) |
| 89 | enum { value = false }; |
| 90 | # else |
| 91 | BOOST_STATIC_CONSTANT(bool, value=false); |
| 92 | # endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) |
| 93 | |
| 94 | typedef mpl::bool_<has_const_time_insert<T>::value> type; |
| 95 | }; |
| 96 | |
| 97 | |
| 98 | //! Const time erase trait |
| 99 | /*! |
| 100 | This trait specifies that the sequence's erase method has |
| 101 | constant time complexity. |
| 102 | */ |
| 103 | template< typename T > |
| 104 | class has_const_time_erase |
| 105 | { |
| 106 | public: |
| 107 | # if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) |
| 108 | enum { value = false }; |
| 109 | # else |
| 110 | BOOST_STATIC_CONSTANT(bool, value=false); |
| 111 | # endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) |
| 112 | |
| 113 | typedef mpl::bool_<has_const_time_erase<T>::value> type; |
| 114 | }; |
| 115 | |
| 116 | } // namespace algorithm |
| 117 | } // namespace boost |
| 118 | |
| 119 | |
| 120 | #endif // BOOST_STRING_SEQUENCE_TRAITS_HPP |
| 121 | |