from_string2.fail.cpp 945 B

123456789101112131415161718192021222324252627282930313233
  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-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <string_view>
  9. // template<class Allocator>
  10. // basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept
  11. #include <string_view>
  12. #include <string>
  13. #include <cassert>
  14. struct dummy_char_traits : public std::char_traits<char> {};
  15. int main(int, char**) {
  16. using string_view = std::basic_string_view<char, dummy_char_traits>;
  17. using string = std:: basic_string <char>;
  18. {
  19. string s{"QBCDE"};
  20. string_view sv1 ( s );
  21. assert ( sv1.size() == s.size());
  22. assert ( sv1.data() == s.data());
  23. }
  24. return 0;
  25. }