brintos

brintos / llvm-project-archived public Read only

0
0
Text · 18.9 KiB · 8292750 Raw
545 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___STRING_CHAR_TRAITS_H10#define _LIBCPP___STRING_CHAR_TRAITS_H11 12#include <__algorithm/fill_n.h>13#include <__algorithm/find.h>14#include <__algorithm/find_end.h>15#include <__algorithm/find_first_of.h>16#include <__algorithm/min.h>17#include <__assert>18#include <__compare/ordering.h>19#include <__config>20#include <__cstddef/ptrdiff_t.h>21#include <__functional/hash.h>22#include <__functional/identity.h>23#include <__iterator/iterator_traits.h>24#include <__std_mbstate_t.h>25#include <__string/constexpr_c_functions.h>26#include <__type_traits/is_constant_evaluated.h>27#include <__utility/is_pointer_in_range.h>28#include <cstdint>29#include <cstdio>30#include <iosfwd>31 32#if _LIBCPP_HAS_WIDE_CHARACTERS33#  include <cwchar> // for wmemcpy34#endif35 36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)37#  pragma GCC system_header38#endif39 40_LIBCPP_PUSH_MACROS41#include <__undef_macros>42 43_LIBCPP_BEGIN_NAMESPACE_STD44 45template <class _CharT>46struct char_traits;47/*48The Standard does not define the base template for char_traits because it is impossible to provide49a correct definition for arbitrary character types. Instead, it requires implementations to provide50specializations for predefined character types like `char`, `wchar_t` and others. We provide this as51exposition-only to document what members a char_traits specialization should provide:52{53    using char_type  = _CharT;54    using int_type   = ...;55    using off_type   = ...;56    using pos_type   = ...;57    using state_type = ...;58 59    static void assign(char_type&, const char_type&);60    static bool eq(char_type, char_type);61    static bool lt(char_type, char_type);62 63    static int              compare(const char_type*, const char_type*, size_t);64    static size_t           length(const char_type*);65    static const char_type* find(const char_type*, size_t, const char_type&);66    static char_type*       move(char_type*, const char_type*, size_t);67    static char_type*       copy(char_type*, const char_type*, size_t);68    static char_type*       assign(char_type*, size_t, char_type);69 70    static int_type  not_eof(int_type);71    static char_type to_char_type(int_type);72    static int_type  to_int_type(char_type);73    static bool      eq_int_type(int_type, int_type);74    static int_type  eof();75};76*/77 78// char_traits<char>79 80template <>81struct char_traits<char> {82  using char_type  = char;83  using int_type   = int;84  using off_type   = streamoff;85  using pos_type   = streampos;86  using state_type = mbstate_t;87#if _LIBCPP_STD_VER >= 2088  using comparison_category = strong_ordering;89#endif90 91  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void92  assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {93    __c1 = __c2;94  }95 96  // TODO: Make this _LIBCPP_HIDE_FROM_ABI97  static inline _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {98    return __c1 == __c2;99  }100  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {101    return (unsigned char)__c1 < (unsigned char)__c2;102  }103 104  // __constexpr_memcmp requires a trivially lexicographically comparable type, but char is not when char is a signed105  // type106  static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int107  compare(const char_type* __lhs, const char_type* __rhs, size_t __count) _NOEXCEPT {108    if (__libcpp_is_constant_evaluated()) {109#ifdef _LIBCPP_COMPILER_CLANG_BASED110      return __builtin_memcmp(__lhs, __rhs, __count);111#else112      while (__count != 0) {113        if (lt(*__lhs, *__rhs))114          return -1;115        if (lt(*__rhs, *__lhs))116          return 1;117 118        __count -= sizeof(char_type);119        ++__lhs;120        ++__rhs;121      }122      return 0;123#endif // _LIBCPP_COMPILER_CLANG_BASED124    } else {125      return __builtin_memcmp(__lhs, __rhs, __count);126    }127  }128 129  static inline _LIBCPP_HIDE_FROM_ABI size_t _LIBCPP_CONSTEXPR_SINCE_CXX17 length(const char_type* __s) _NOEXCEPT {130    return std::__constexpr_strlen(__s);131  }132 133  static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*134  find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {135    return std::__constexpr_memchr(__s, __a, __n);136  }137 138  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*139  move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {140    return std::__constexpr_memmove(__s1, __s2, __element_count(__n));141  }142 143  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*144  copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {145    _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2),146                                          "char_traits::copy: source and destination ranges overlap");147    std::__constexpr_memmove(__s1, __s2, __element_count(__n));148    return __s1;149  }150 151  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*152  assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {153    std::fill_n(__s, __n, __a);154    return __s;155  }156 157  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {158    return eq_int_type(__c, eof()) ? ~eof() : __c;159  }160  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {161    return char_type(__c);162  }163  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {164    return int_type((unsigned char)__c);165  }166  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {167    return __c1 == __c2;168  }169  static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(EOF); }170};171 172template <class _CharT, class _IntT, _IntT _EOFVal>173struct __char_traits_base {174  using char_type  = _CharT;175  using int_type   = _IntT;176  using off_type   = streamoff;177  using state_type = mbstate_t;178#if _LIBCPP_STD_VER >= 20179  using comparison_category = strong_ordering;180#endif181 182  // There are different aliases for the different char types, but they are all aliases to this type183  using pos_type = fpos<mbstate_t>;184 185  _LIBCPP_HIDE_FROM_ABI static inline _LIBCPP_CONSTEXPR_SINCE_CXX17 void186  assign(char_type& __lhs, const char_type& __rhs) _NOEXCEPT {187    __lhs = __rhs;188  }189 190  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq(char_type __lhs, char_type __rhs) _NOEXCEPT {191    return __lhs == __rhs;192  }193 194  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool lt(char_type __lhs, char_type __rhs) _NOEXCEPT {195    return __lhs < __rhs;196  }197 198  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*199  move(char_type* __dest, const char_type* __src, size_t __n) _NOEXCEPT {200    return std::__constexpr_memmove(__dest, __src, __element_count(__n));201  }202 203  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*204  copy(char_type* __dest, const char_type* __src, size_t __n) _NOEXCEPT {205    _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__dest, __dest + __n, __src),206                                          "char_traits::copy: source and destination ranges overlap");207    return std::__constexpr_memmove(__dest, __src, __element_count(__n));208  }209 210  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*211  assign(char_type* __str, size_t __n, char_type __fill_char) _NOEXCEPT {212    std::fill_n(__str, __n, __fill_char);213    return __str;214  }215 216  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {217    return char_type(__c);218  }219 220  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { return int_type(__c); }221 222  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __lhs, int_type __rhs) _NOEXCEPT {223    return __lhs == __rhs;224  }225 226  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return _EOFVal; }227 228  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {229    return eq_int_type(__c, eof()) ? static_cast<int_type>(~eof()) : __c;230  }231};232 233// char_traits<wchar_t>234 235#if _LIBCPP_HAS_WIDE_CHARACTERS236template <>237struct char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> {238  static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int239  compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {240    if (__n == 0)241      return 0;242    return std::__constexpr_wmemcmp(__s1, __s2, __n);243  }244 245  static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT {246    return std::__constexpr_wcslen(__s);247  }248 249  static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*250  find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {251    return std::__constexpr_wmemchr(__s, __a, __n);252  }253};254#endif // _LIBCPP_HAS_WIDE_CHARACTERS255 256#if _LIBCPP_HAS_CHAR8_T257 258template <>259struct char_traits<char8_t> : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> {260  static _LIBCPP_HIDE_FROM_ABI constexpr int261  compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept {262    return std::__constexpr_memcmp(__s1, __s2, __element_count(__n));263  }264 265  static _LIBCPP_HIDE_FROM_ABI constexpr size_t length(const char_type* __str) noexcept {266    return std::__constexpr_strlen(__str);267  }268 269  _LIBCPP_HIDE_FROM_ABI static constexpr const char_type*270  find(const char_type* __s, size_t __n, const char_type& __a) noexcept {271    return std::__constexpr_memchr(__s, __a, __n);272  }273};274 275#endif // _LIBCPP_HAS_CHAR8_T276 277template <>278struct char_traits<char16_t> : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> {279  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int280  compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;281  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;282 283  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*284  find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {285    __identity __proj;286    const char_type* __match = std::__find(__s, __s + __n, __a, __proj);287    if (__match == __s + __n)288      return nullptr;289    return __match;290  }291};292 293inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int294char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {295  for (; __n; --__n, ++__s1, ++__s2) {296    if (lt(*__s1, *__s2))297      return -1;298    if (lt(*__s2, *__s1))299      return 1;300  }301  return 0;302}303 304inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT {305  size_t __len = 0;306  for (; !eq(*__s, char_type(0)); ++__s)307    ++__len;308  return __len;309}310 311template <>312struct char_traits<char32_t> : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> {313  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int314  compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;315  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;316 317  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*318  find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {319    __identity __proj;320    const char_type* __match = std::__find(__s, __s + __n, __a, __proj);321    if (__match == __s + __n)322      return nullptr;323    return __match;324  }325};326 327inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int328char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {329  for (; __n; --__n, ++__s1, ++__s2) {330    if (lt(*__s1, *__s2))331      return -1;332    if (lt(*__s2, *__s1))333      return 1;334  }335  return 0;336}337 338inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT {339  size_t __len = 0;340  for (; !eq(*__s, char_type(0)); ++__s)341    ++__len;342  return __len;343}344 345// helper fns for basic_string and string_view346 347// __str_find348template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>349inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI350__str_find(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {351  if (__pos > __sz)352    return __npos;353  const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);354  if (__r == nullptr)355    return __npos;356  return static_cast<_SizeT>(__r - __p);357}358 359template <class _CharT, class _Traits>360_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 const _CharT* __search_substring(361    const _CharT* __first1, const _CharT* __last1, const _CharT* __first2, const _CharT* __last2) _NOEXCEPT {362  // Take advantage of knowing source and pattern lengths.363  // Stop short when source is smaller than pattern.364  const ptrdiff_t __len2 = __last2 - __first2;365  if (__len2 == 0)366    return __first1;367 368  ptrdiff_t __len1 = __last1 - __first1;369  if (__len1 < __len2)370    return __last1;371 372  if (__builtin_constant_p(__len2 == 1) && __len2 == 1) {373    auto __res = _Traits::find(__first1, __len1, *__first2);374    if (__res == nullptr)375      return __last1;376    return __res;377  }378 379  // First element of __first2 is loop invariant.380  _CharT __f2 = *__first2;381  while (true) {382    __len1 = __last1 - __first1;383    // Check whether __first1 still has at least __len2 bytes.384    if (__len1 < __len2)385      return __last1;386 387    // Find __f2 the first byte matching in __first1.388    __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);389    if (__first1 == nullptr)390      return __last1;391 392    // It is faster to compare from the first byte of __first1 even if we393    // already know that it matches the first byte of __first2: this is because394    // __first2 is most likely aligned, as it is user's "pattern" string, and395    // __first1 + 1 is most likely not aligned, as the match is in the middle of396    // the string.397    if (_Traits::compare(__first1, __first2, __len2) == 0)398      return __first1;399 400    ++__first1;401  }402}403 404template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>405inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI406__str_find(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {407  if (__pos > __sz)408    return __npos;409 410  if (__n == 0) // There is nothing to search, just return __pos.411    return __pos;412 413  const _CharT* __r = std::__search_substring<_CharT, _Traits>(__p + __pos, __p + __sz, __s, __s + __n);414 415  if (__r == __p + __sz)416    return __npos;417  return static_cast<_SizeT>(__r - __p);418}419 420// __str_rfind421 422template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>423inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI424__str_rfind(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {425  if (__sz < 1)426    return __npos;427  if (__pos < __sz)428    ++__pos;429  else430    __pos = __sz;431  for (const _CharT* __ps = __p + __pos; __ps != __p;) {432    if (_Traits::eq(*--__ps, __c))433      return static_cast<_SizeT>(__ps - __p);434  }435  return __npos;436}437 438template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>439inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI440__str_rfind(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {441  __pos = std::min(__pos, __sz);442  if (__n < __sz - __pos)443    __pos += __n;444  else445    __pos = __sz;446  const _CharT* __r = std::__find_end_classic(__p, __p + __pos, __s, __s + __n, _Traits::eq);447  if (__n > 0 && __r == __p + __pos)448    return __npos;449  return static_cast<_SizeT>(__r - __p);450}451 452// __str_find_first_of453template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>454inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI455__str_find_first_of(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {456  if (__pos >= __sz || __n == 0)457    return __npos;458  const _CharT* __r = std::__find_first_of_ce(__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq);459  if (__r == __p + __sz)460    return __npos;461  return static_cast<_SizeT>(__r - __p);462}463 464// __str_find_last_of465template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>466inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI467__str_find_last_of(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {468  if (__n != 0) {469    if (__pos < __sz)470      ++__pos;471    else472      __pos = __sz;473    for (const _CharT* __ps = __p + __pos; __ps != __p;) {474      const _CharT* __r = _Traits::find(__s, __n, *--__ps);475      if (__r)476        return static_cast<_SizeT>(__ps - __p);477    }478  }479  return __npos;480}481 482// __str_find_first_not_of483template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>484inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI485__str_find_first_not_of(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {486  if (__pos < __sz) {487    const _CharT* __pe = __p + __sz;488    for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)489      if (_Traits::find(__s, __n, *__ps) == nullptr)490        return static_cast<_SizeT>(__ps - __p);491  }492  return __npos;493}494 495template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>496inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI497__str_find_first_not_of(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {498  if (__pos < __sz) {499    const _CharT* __pe = __p + __sz;500    for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)501      if (!_Traits::eq(*__ps, __c))502        return static_cast<_SizeT>(__ps - __p);503  }504  return __npos;505}506 507// __str_find_last_not_of508template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>509inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI510__str_find_last_not_of(const _CharT* __p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT {511  if (__pos < __sz)512    ++__pos;513  else514    __pos = __sz;515  for (const _CharT* __ps = __p + __pos; __ps != __p;)516    if (_Traits::find(__s, __n, *--__ps) == nullptr)517      return static_cast<_SizeT>(__ps - __p);518  return __npos;519}520 521template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>522inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI523__str_find_last_not_of(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {524  if (__pos < __sz)525    ++__pos;526  else527    __pos = __sz;528  for (const _CharT* __ps = __p + __pos; __ps != __p;)529    if (!_Traits::eq(*--__ps, __c))530      return static_cast<_SizeT>(__ps - __p);531  return __npos;532}533 534template <class _Ptr>535inline _LIBCPP_HIDE_FROM_ABI size_t __do_string_hash(_Ptr __p, _Ptr __e) {536  typedef typename iterator_traits<_Ptr>::value_type value_type;537  return std::__hash_memory(__p, (__e - __p) * sizeof(value_type));538}539 540_LIBCPP_END_NAMESPACE_STD541 542_LIBCPP_POP_MACROS543 544#endif // _LIBCPP___STRING_CHAR_TRAITS_H545