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