sequence_traits.hpp 3.8 KB

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