Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:15

0001 //
0002 // Copyright (c) 2022-2023 Alexander Grund
0003 //
0004 // Distributed under the Boost Software License, Version 1.0.
0005 // https://www.boost.org/LICENSE_1_0.txt
0006 
0007 #ifndef BOOST_LOCALE_UTIL_STRING_HPP
0008 #define BOOST_LOCALE_UTIL_STRING_HPP
0009 
0010 #include <boost/locale/config.hpp>
0011 #include <limits>
0012 
0013 namespace boost { namespace locale { namespace util {
0014     /// Return the end of a C-string, i.e. the pointer to the trailing NULL byte
0015     template<typename Char>
0016     Char* str_end(Char* str)
0017     {
0018         while(*str)
0019             ++str;
0020         return str;
0021     }
0022 
0023     inline constexpr bool is_upper_ascii(const char c)
0024     {
0025         return 'A' <= c && c <= 'Z';
0026     }
0027 
0028     inline constexpr bool is_lower_ascii(const char c)
0029     {
0030         return 'a' <= c && c <= 'z';
0031     }
0032 
0033     inline constexpr bool is_numeric_ascii(const char c)
0034     {
0035         return '0' <= c && c <= '9';
0036     }
0037 
0038     /// Cast an unsigned char to a (possibly signed) char avoiding implementation defined behavior
0039     constexpr char to_char(unsigned char c)
0040     {
0041         return static_cast<char>((c - (std::numeric_limits<char>::min)()) + (std::numeric_limits<char>::min)());
0042     }
0043 
0044 }}} // namespace boost::locale::util
0045 
0046 #endif