char_traits.hpp 976 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // char_traits.hpp
  2. // Copyright (c) 2007-2009 Ben Hanson (http://www.benhanson.net/)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file licence_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_LEXER_CHAR_TRAITS_H
  7. #define BOOST_LEXER_CHAR_TRAITS_H
  8. // Make sure wchar_t is defined
  9. #include <string>
  10. namespace boost
  11. {
  12. namespace lexer
  13. {
  14. template<typename CharT>
  15. struct char_traits
  16. {
  17. typedef CharT char_type;
  18. typedef CharT index_type;
  19. static index_type call (CharT ch)
  20. {
  21. return ch;
  22. }
  23. };
  24. template<>
  25. struct char_traits<char>
  26. {
  27. typedef char char_type;
  28. typedef unsigned char index_type;
  29. static index_type call (char ch)
  30. {
  31. return static_cast<index_type>(ch);
  32. }
  33. };
  34. template<>
  35. struct char_traits<wchar_t>
  36. {
  37. typedef wchar_t char_type;
  38. typedef wchar_t index_type;
  39. static index_type call (wchar_t ch)
  40. {
  41. return ch;
  42. }
  43. };
  44. }
  45. }
  46. #endif