File size: 29,272 Bytes
7791ca1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | #pragma once
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
/**
* To keep ABI compatability, we use CRT's own string view implementation even for C++ 17.
*/
#include <algorithm>
#include <cassert>
#include <iterator>
#include <limits>
#include <stddef.h>
#include <string>
#include <type_traits>
#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
# include <string_view>
#endif
namespace Aws
{
namespace Crt
{
/**
* Custom string view implementation in order to meet C++11 baseline
* @tparam CharT
* @tparam Traits
*/
template <typename CharT, typename Traits = std::char_traits<CharT>> class basic_string_view
{
public:
// types
using traits_type = Traits;
using value_type = CharT;
using pointer = value_type *;
using const_pointer = const value_type *;
using reference = value_type &;
using const_reference = const value_type &;
using const_iterator = const value_type *;
using iterator = const_iterator;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using reverse_iterator = const_reverse_iterator;
using size_type = size_t;
using difference_type = ptrdiff_t;
static constexpr size_type npos = static_cast<size_type>(-1);
// constructors and assignment
constexpr basic_string_view() noexcept : m_size{0}, m_data{nullptr} {}
constexpr basic_string_view(const basic_string_view &) noexcept = default;
constexpr basic_string_view(const CharT *s) noexcept : m_size{traits_type::length(s)}, m_data{s} {}
constexpr basic_string_view(const CharT *s, size_type count) noexcept : m_size{count}, m_data{s} {}
basic_string_view &operator=(const basic_string_view &) noexcept = default;
#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
constexpr basic_string_view(const std::basic_string_view<CharT, Traits> &other) noexcept
: m_size(other.size()), m_data(other.data())
{
}
basic_string_view &operator=(const std::basic_string_view<CharT, Traits> &other) noexcept
{
m_data = other->data();
m_size = other->size();
return *this;
}
#endif
// iterators
constexpr const_iterator begin() const noexcept { return this->m_data; }
constexpr const_iterator end() const noexcept { return this->m_data + this->m_size; }
constexpr const_iterator cbegin() const noexcept { return this->m_data; }
constexpr const_iterator cend() const noexcept { return this->m_data + this->m_size; }
constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(this->end()); }
constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(this->begin()); }
constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(this->end()); }
constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(this->begin()); }
constexpr size_type size() const noexcept { return this->m_size; }
constexpr size_type length() const noexcept { return this->m_size; }
constexpr size_type max_size() const noexcept { return (std::numeric_limits<size_type>::max)(); }
constexpr bool empty() const noexcept { return this->m_size == 0; }
// element accessors
const_reference operator[](size_type pos) const noexcept
{
assert(pos < m_size);
return *(this->m_data + pos);
}
const_reference at(size_type pos) const
{
assert(pos < m_size);
return *(this->m_data + pos);
}
const_reference front() const noexcept
{
assert(m_size > 0);
return *this->m_data;
}
const_reference back() const noexcept
{
assert(m_size > 0);
return *(this->m_data + this->m_size - 1);
}
constexpr const_pointer data() const noexcept { return this->m_data; }
// modifiers
void remove_prefix(size_type n) noexcept
{
assert(this->m_size >= n);
this->m_data += n;
this->m_size -= n;
}
void remove_suffix(size_type n) noexcept { this->m_size -= n; }
void swap(basic_string_view &other) noexcept
{
auto tmp = *this;
*this = other;
other = tmp;
}
// string operations
size_type copy(CharT *s, size_type n, size_type pos = 0) const
{
assert(pos <= size());
const size_type copyLen = (std::min)(n, m_size - pos);
traits_type::copy(s, data() + pos, copyLen);
return copyLen;
}
basic_string_view substr(size_type pos = 0, size_type n = npos) const noexcept(false)
{
assert(pos <= size());
const size_type copyLen = (std::min)(n, m_size - pos);
return basic_string_view{m_data + pos, copyLen};
}
int compare(const basic_string_view &s) const noexcept
{
const size_type compareLen = (std::min)(this->m_size, s.m_size);
int ret = traits_type::compare(this->m_data, s.m_data, compareLen);
if (ret == 0)
{
ret = _s_compare(this->m_size, s.m_size);
}
return ret;
}
constexpr int compare(size_type pos1, size_type n1, const basic_string_view &s) const
{
return this->substr(pos1, n1).compare(s);
}
constexpr int compare(
size_type pos1,
size_type n1,
const basic_string_view &s,
size_type pos2,
size_type n2) const
{
return this->substr(pos1, n1).compare(s.substr(pos2, n2));
}
constexpr int compare(const CharT *s) const noexcept { return this->compare(basic_string_view{s}); }
constexpr int compare(size_type pos1, size_type n1, const CharT *s) const
{
return this->substr(pos1, n1).compare(basic_string_view{s});
}
constexpr int compare(size_type pos1, size_type n1, const CharT *s, size_type n2) const noexcept(false)
{
return this->substr(pos1, n1).compare(basic_string_view(s, n2));
}
constexpr bool starts_with(const basic_string_view &other) const noexcept
{
return this->substr(0, other.size()) == other;
}
constexpr bool starts_with(CharT c) const noexcept
{
return !this->empty() && traits_type::eq(this->front(), c);
}
constexpr bool starts_with(const CharT *s) const noexcept
{
return this->starts_with(basic_string_view(s));
}
constexpr bool ends_with(const basic_string_view &other) const noexcept
{
return this->m_size >= other.m_size && this->compare(this->m_size - other.m_size, npos, other) == 0;
}
constexpr bool ends_with(CharT c) const noexcept
{
return !this->empty() && traits_type::eq(this->back(), c);
}
constexpr bool ends_with(const CharT *s) const noexcept { return this->ends_with(basic_string_view(s)); }
// find utilities
constexpr size_type find(const basic_string_view &s, size_type pos = 0) const noexcept
{
return this->find(s.m_data, pos, s.m_size);
}
size_type find(CharT c, size_type pos = 0) const noexcept
{
if (pos >= m_size)
{
return npos;
}
const CharT *r = Traits::find(m_data + pos, m_size - pos, c);
if (r == nullptr)
{
return npos;
}
return static_cast<size_type>(r - m_data);
}
size_type find(const CharT *s, size_type pos, size_type n) const noexcept
{
if (n && !s)
{
return npos;
}
if (pos > m_size)
{
return npos;
}
if (n == 0)
{
return pos;
}
const CharT *r = _s_search_substr(m_data + pos, m_data + m_size, s, s + n);
if (r == m_data + m_size)
{
return npos;
}
return static_cast<size_type>(r - m_data);
}
constexpr size_type find(const CharT *s, size_type pos = 0) const noexcept
{
return this->find(s, pos, traits_type::length(s));
}
size_type rfind(basic_string_view s, size_type pos = npos) const noexcept
{
if (s.m_size && !s.m_data)
{
return npos;
}
return this->rfind(s.m_data, pos, s.m_size);
}
size_type rfind(CharT c, size_type pos = npos) const noexcept
{
if (m_size <= 0)
{
return npos;
}
if (pos < m_size)
{
++pos;
}
else
{
pos = m_size;
}
for (const CharT *ptr = m_data + pos; ptr != m_data;)
{
if (Traits::eq(*--ptr, c))
{
return static_cast<size_type>(ptr - m_data);
}
}
return npos;
}
size_type rfind(const CharT *s, size_type pos, size_type n) const noexcept
{
if (n && !s)
{
return npos;
}
pos = (std::min)(pos, m_size);
if (n < m_size - pos)
{
pos += n;
}
else
{
pos = m_size;
}
const CharT *r = _s_find_end(m_data, m_data + pos, s, s + n);
if (n > 0 && r == m_data + pos)
{
return npos;
}
return static_cast<size_type>(r - m_data);
}
constexpr size_type rfind(const CharT *s, size_type pos = npos) const noexcept
{
return this->rfind(s, pos, traits_type::length(s));
}
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept
{
return this->find_first_of(s.m_data, pos, s.m_size);
}
constexpr size_type find_first_of(CharT c, size_type pos = 0) const noexcept { return this->find(c, pos); }
size_type find_first_of(const CharT *s, size_type pos, size_type n) const noexcept
{
if (pos >= m_size || !n || !s)
{
return npos;
}
const CharT *r = _s_find_first_of_ce(m_data + pos, m_data + m_size, s, s + n);
if (r == m_data + m_size)
{
return npos;
}
return static_cast<size_type>(r - m_data);
}
constexpr size_type find_first_of(const CharT *s, size_type pos = 0) const noexcept
{
return this->find_first_of(s, pos, traits_type::length(s));
}
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept
{
return this->find_last_of(s.m_data, pos, s.m_size);
}
constexpr size_type find_last_of(CharT c, size_type pos = npos) const noexcept
{
return this->rfind(c, pos);
}
size_type find_last_of(const CharT *s, size_type pos, size_type n) const noexcept
{
if (!n || s == nullptr)
{
return npos;
}
if (pos < m_size)
{
++pos;
}
else
{
pos = m_size;
}
for (const CharT *ptr = m_data + pos; ptr != m_data;)
{
const CharT *r = Traits::find(s, n, *--ptr);
if (r)
{
return static_cast<size_type>(ptr - m_data);
}
}
return npos;
}
constexpr size_type find_last_of(const CharT *s, size_type pos = npos) const noexcept
{
return this->find_last_of(s, pos, traits_type::length(s));
}
size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept
{
if (s.m_size && !s.m_data)
{
return npos;
}
return this->find_first_not_of(s.m_data, pos, s.m_size);
}
size_type find_first_not_of(CharT c, size_type pos = 0) const noexcept
{
if (!m_data || pos >= m_size)
{
return npos;
}
const CharT *pend = m_data + m_size;
for (const CharT *ptr = m_data + pos; ptr != pend; ++ptr)
{
if (!Traits::eq(*ptr, c))
{
return static_cast<size_type>(ptr - m_data);
}
}
return npos;
}
size_type find_first_not_of(const CharT *s, size_type pos, size_type n) const noexcept
{
if (n && s == nullptr)
{
return npos;
}
if (m_data == nullptr || pos >= m_size)
{
return npos;
}
const CharT *pend = m_data + m_size;
for (const CharT *ptr = m_data + pos; ptr != pend; ++ptr)
{
if (Traits::find(s, n, *ptr) == 0)
{
return static_cast<size_type>(ptr - m_data);
}
}
return npos;
}
constexpr size_type find_first_not_of(const CharT *s, size_type pos = 0) const noexcept
{
return this->find_first_not_of(s, pos, traits_type::length(s));
}
size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept
{
if (s.m_size && !s.m_data)
{
return npos;
}
return this->find_last_not_of(s.m_data, pos, s.m_size);
}
size_type find_last_not_of(CharT c, size_type pos = npos) const noexcept
{
if (pos < m_size)
{
++pos;
}
else
{
pos = m_size;
}
for (const CharT *ptr = m_data + pos; ptr != m_data;)
{
if (!Traits::eq(*--ptr, c))
{
return static_cast<size_type>(ptr - m_data);
}
}
return npos;
}
size_type find_last_not_of(const CharT *s, size_type pos, size_type n) const noexcept
{
if (n && !s)
{
return npos;
}
if (pos < m_size)
{
++pos;
}
else
{
pos = m_size;
}
for (const CharT *ptr = m_data + pos; ptr != m_data;)
{
if (Traits::find(s, n, *--ptr) == 0)
{
return static_cast<size_type>(ptr - m_data);
}
}
return npos;
}
constexpr size_type find_last_not_of(const CharT *s, size_type pos = npos) const noexcept
{
return this->find_last_not_of(s, pos, traits_type::length(s));
}
private:
static int _s_compare(size_type n1, size_type n2) noexcept
{
const difference_type diff = n1 - n2;
if (diff > (std::numeric_limits<int>::max)())
{
return (std::numeric_limits<int>::max)();
}
if (diff < (std::numeric_limits<int>::min)())
{
return (std::numeric_limits<int>::min)();
}
return static_cast<int>(diff);
}
static const CharT *_s_search_substr(
const CharT *first1,
const CharT *last1,
const CharT *first2,
const CharT *last2)
{
const ptrdiff_t length2 = last2 - first2;
if (length2 == 0)
{
return first1;
}
ptrdiff_t length1 = last1 - first1;
if (length1 < length2)
{
return last1;
}
while (true)
{
length1 = last1 - first1;
if (length1 < length2)
{
return last1;
}
first1 = Traits::find(first1, length1 - length2 + 1, *first2);
if (first1 == 0)
{
return last1;
}
if (Traits::compare(first1, first2, length2) == 0)
{
return first1;
}
++first1;
}
}
static const CharT *_s_find_end(
const CharT *first1,
const CharT *last1,
const CharT *first2,
const CharT *last2)
{
const CharT *r = last1;
if (first2 == last2)
{
return r;
}
while (true)
{
while (true)
{
if (first1 == last1)
{
return r;
}
if (Traits::eq(*first1, *first2))
{
break;
}
++first1;
}
const CharT *m1 = first1;
const CharT *m2 = first2;
while (true)
{
if (++m2 == last2)
{
r = first1;
++first1;
break;
}
if (++m1 == last1)
{
return r;
}
if (!Traits::eq(*m1, *m2))
{
++first1;
break;
}
}
}
}
static const CharT *_s_find_first_of_ce(
const CharT *first1,
const CharT *last1,
const CharT *first2,
const CharT *last2)
{
for (; first1 != last1; ++first1)
{
for (const CharT *ptr = first2; ptr != last2; ++ptr)
{
if (Traits::eq(*first1, *ptr))
{
return first1;
}
}
}
return last1;
}
size_type m_size;
const CharT *m_data;
};
// operator ==
template <class CharT, class Traits>
bool operator==(
const basic_string_view<CharT, Traits> &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return (lhs.size() != rhs.size()) ? false : lhs.compare(rhs) == 0;
}
template <class CharT, class Traits>
bool operator==(
const basic_string_view<CharT, Traits> &lhs,
typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
{
return (lhs.size() != rhs.size()) ? false : lhs.compare(rhs) == 0;
}
template <class CharT, class Traits>
bool operator==(
typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return (lhs.size() != rhs.size()) ? false : lhs.compare(rhs) == 0;
}
// operator !=
template <class CharT, class Traits>
bool operator!=(
const basic_string_view<CharT, Traits> &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return (lhs.size() != rhs.size()) ? true : lhs.compare(rhs) != 0;
}
template <class CharT, class Traits>
bool operator!=(
const basic_string_view<CharT, Traits> &lhs,
typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
{
return (lhs.size() != rhs.size()) ? true : lhs.compare(rhs) != 0;
}
template <class CharT, class Traits>
bool operator!=(
typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return (lhs.size() != rhs.size()) ? true : lhs.compare(rhs) != 0;
}
// operator <
template <class CharT, class Traits>
bool operator<(
const basic_string_view<CharT, Traits> &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return lhs.compare(rhs) < 0;
}
template <class CharT, class Traits>
constexpr bool operator<(
const basic_string_view<CharT, Traits> &lhs,
typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
{
return lhs.compare(rhs) < 0;
}
template <class CharT, class Traits>
constexpr bool operator<(
typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return lhs.compare(rhs) < 0;
}
// operator >
template <class CharT, class Traits>
constexpr bool operator>(
const basic_string_view<CharT, Traits> &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return lhs.compare(rhs) > 0;
}
template <class CharT, class Traits>
constexpr bool operator>(
const basic_string_view<CharT, Traits> &lhs,
typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
{
return lhs.compare(rhs) > 0;
}
template <class CharT, class Traits>
constexpr bool operator>(
typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return lhs.compare(rhs) > 0;
}
// operator <=
template <class CharT, class Traits>
constexpr bool operator<=(
const basic_string_view<CharT, Traits> &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return lhs.compare(rhs) <= 0;
}
template <class CharT, class Traits>
constexpr bool operator<=(
const basic_string_view<CharT, Traits> &lhs,
typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
{
return lhs.compare(rhs) <= 0;
}
template <class CharT, class Traits>
constexpr bool operator<=(
typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return lhs.compare(rhs) <= 0;
}
// operator >=
template <class CharT, class Traits>
constexpr bool operator>=(
const basic_string_view<CharT, Traits> &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return lhs.compare(rhs) >= 0;
}
template <class CharT, class Traits>
constexpr bool operator>=(
const basic_string_view<CharT, Traits> &lhs,
typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
{
return lhs.compare(rhs) >= 0;
}
template <class CharT, class Traits>
constexpr bool operator>=(
typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
const basic_string_view<CharT, Traits> &rhs) noexcept
{
return lhs.compare(rhs) >= 0;
}
typedef basic_string_view<char> string_view;
typedef basic_string_view<char16_t> u16string_view;
typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<wchar_t> wstring_view;
inline namespace literals
{
inline namespace string_view_literals
{
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ <= 8)
/* On GCC <= 4.8, use old syntax for literal operator (with space after ""). It can't do the modern syntax */
# define OPERATOR_LITERAL_SV operator"" _sv
#else
/* else use modern syntax (no space after "") to avoid -Wdeprecated-literal-operator warning on Clang 16+ */
# define OPERATOR_LITERAL_SV operator""_sv
#endif
inline basic_string_view<char> OPERATOR_LITERAL_SV(const char *s, size_t length) noexcept
{
return basic_string_view<char>(s, length);
}
inline basic_string_view<wchar_t> OPERATOR_LITERAL_SV(const wchar_t *s, size_t length) noexcept
{
return basic_string_view<wchar_t>(s, length);
}
inline basic_string_view<char16_t> OPERATOR_LITERAL_SV(const char16_t *s, size_t length) noexcept
{
return basic_string_view<char16_t>(s, length);
}
inline basic_string_view<char32_t> OPERATOR_LITERAL_SV(const char32_t *s, size_t length) noexcept
{
return basic_string_view<char32_t>(s, length);
}
#undef OPERATOR_LITERAL_SV
} // namespace string_view_literals
} // namespace literals
using StringView = string_view;
} // namespace Crt
} // namespace Aws
// hash
namespace std
{
template <class CharT, class Traits> struct hash<Aws::Crt::basic_string_view<CharT, Traits>>
{
size_t operator()(const Aws::Crt::basic_string_view<CharT, Traits> &val) const noexcept;
};
template <class CharT, class Traits>
size_t hash<Aws::Crt::basic_string_view<CharT, Traits>>::operator()(
const Aws::Crt::basic_string_view<CharT, Traits> &val) const noexcept
{
auto str = std::basic_string<CharT, Traits>(val.data(), val.size());
return std::hash<std::basic_string<CharT, Traits>>{}(str);
}
} // namespace std
|