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 9 // Make sure wchar_t is defined 10 #include <string> 11 12 namespace boost 13 { 14 namespace lexer 15 { 16 template<typename CharT> 17 struct char_traits 18 { 19 typedef CharT char_type; 20 typedef CharT index_type; 21 callboost::lexer::char_traits22 static index_type call (CharT ch) 23 { 24 return ch; 25 } 26 }; 27 28 template<> 29 struct char_traits<char> 30 { 31 typedef char char_type; 32 typedef unsigned char index_type; 33 callboost::lexer::char_traits34 static index_type call (char ch) 35 { 36 return static_cast<index_type>(ch); 37 } 38 }; 39 40 template<> 41 struct char_traits<wchar_t> 42 { 43 typedef wchar_t char_type; 44 typedef wchar_t index_type; 45 callboost::lexer::char_traits46 static index_type call (wchar_t ch) 47 { 48 return ch; 49 } 50 }; 51 } 52 } 53 54 #endif 55