1 // Boost string_algo library sequence_traits.hpp header file ---------------------------//
3 // Copyright Pavol Droba 2002-2003.
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)
9 // See http://www.boost.org/ for updates, documentation, and revision history.
11 #ifndef BOOST_STRING_SEQUENCE_TRAITS_HPP
12 #define BOOST_STRING_SEQUENCE_TRAITS_HPP
14 #include <boost/config.hpp>
15 #include <boost/mpl/bool.hpp>
16 #include <boost/algorithm/string/yes_no_type.hpp>
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
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.
37 // sequence traits -----------------------------------------------//
40 //! Native replace trait
42 This trait specifies that the sequence has \c std::string like replace method
44 template< typename T >
45 class has_native_replace
49 # if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
50 enum { value = false };
52 BOOST_STATIC_CONSTANT(bool, value=false);
53 # endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
56 typedef mpl::bool_<has_native_replace<T>::value> type;
60 //! Stable iterators trait
62 This trait specifies that the sequence has stable iterators. It means
63 that operations like insert/erase/replace do not invalidate iterators.
65 template< typename T >
66 class has_stable_iterators
69 # if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
70 enum { value = false };
72 BOOST_STATIC_CONSTANT(bool, value=false);
73 # endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
75 typedef mpl::bool_<has_stable_iterators<T>::value> type;
79 //! Const time insert trait
81 This trait specifies that the sequence's insert method has
82 constant time complexity.
84 template< typename T >
85 class has_const_time_insert
88 # if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
89 enum { value = false };
91 BOOST_STATIC_CONSTANT(bool, value=false);
92 # endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
94 typedef mpl::bool_<has_const_time_insert<T>::value> type;
98 //! Const time erase trait
100 This trait specifies that the sequence's erase method has
101 constant time complexity.
103 template< typename T >
104 class has_const_time_erase
107 # if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
108 enum { value = false };
110 BOOST_STATIC_CONSTANT(bool, value=false);
111 # endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
113 typedef mpl::bool_<has_const_time_erase<T>::value> type;
116 } // namespace algorithm
120 #endif // BOOST_STRING_SEQUENCE_TRAITS_HPP