_ctraits_fns.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) 1999
  3. * Silicon Graphics Computer Systems, Inc.
  4. *
  5. * Permission to use, copy, modify, distribute and sell this software
  6. * and its documentation for any purpose is hereby granted without fee,
  7. * provided that the above copyright notice appear in all copies and
  8. * that both that copyright notice and this permission notice appear
  9. * in supporting documentation. Silicon Graphics makes no
  10. * representations about the suitability of this software for any
  11. * purpose. It is provided "as is" without express or implied warranty.
  12. */
  13. // WARNING: This is an internal header file, included by other C++
  14. // standard library headers. You should not attempt to use this header
  15. // file directly.
  16. #ifndef _STLP_INTERNAL_CTRAITS_FUNCTIONS_H
  17. #define _STLP_INTERNAL_CTRAITS_FUNCTIONS_H
  18. #ifndef _STLP_INTERNAL_FUNCTION_BASE_H
  19. # include <stl/_function_base.h>
  20. #endif
  21. // This file contains a few small adapters that allow a character
  22. // traits class to be used as a function object.
  23. _STLP_BEGIN_NAMESPACE
  24. _STLP_MOVE_TO_PRIV_NAMESPACE
  25. template <class _Traits>
  26. struct _Eq_traits
  27. : public binary_function<typename _Traits::char_type,
  28. typename _Traits::char_type,
  29. bool> {
  30. bool operator()(const typename _Traits::char_type& __x,
  31. const typename _Traits::char_type& __y) const
  32. { return _Traits::eq(__x, __y); }
  33. };
  34. template <class _Traits>
  35. struct _Eq_char_bound
  36. : public unary_function<typename _Traits::char_type, bool> {
  37. typename _Traits::char_type __val;
  38. _Eq_char_bound(typename _Traits::char_type __c) : __val(__c) {}
  39. bool operator()(const typename _Traits::char_type& __x) const
  40. { return _Traits::eq(__x, __val); }
  41. };
  42. template <class _Traits>
  43. struct _Neq_char_bound
  44. : public unary_function<typename _Traits::char_type, bool>
  45. {
  46. typename _Traits::char_type __val;
  47. _Neq_char_bound(typename _Traits::char_type __c) : __val(__c) {}
  48. bool operator()(const typename _Traits::char_type& __x) const
  49. { return !_Traits::eq(__x, __val); }
  50. };
  51. template <class _Traits>
  52. struct _Eq_int_bound
  53. : public unary_function<typename _Traits::char_type, bool> {
  54. typename _Traits::int_type __val;
  55. _Eq_int_bound(typename _Traits::int_type __c) : __val(__c) {}
  56. bool operator()(const typename _Traits::char_type& __x) const
  57. { return _Traits::eq_int_type(_Traits::to_int_type(__x), __val); }
  58. };
  59. #if 0
  60. template <class _Traits>
  61. struct _Lt_traits
  62. : public binary_function<typename _Traits::char_type,
  63. typename _Traits::char_type,
  64. bool> {
  65. bool operator()(const typename _Traits::char_type& __x,
  66. const typename _Traits::char_type& __y) const
  67. { return _Traits::lt(__x, __y); }
  68. };
  69. #endif
  70. _STLP_MOVE_TO_STD_NAMESPACE
  71. _STLP_END_NAMESPACE
  72. #endif /* _STLP_INTERNAL_CTRAITS_FUNCTIONS_H */
  73. // Local Variables:
  74. // mode:C++
  75. // End: