from_string2.fail.cpp 909 B

1234567891011121314151617181920212223242526272829303132
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <string_view>
  10. // template<class Allocator>
  11. // basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept
  12. #include <string_view>
  13. #include <string>
  14. #include <cassert>
  15. struct dummy_char_traits : public std::char_traits<char> {};
  16. int main () {
  17. using string_view = std::basic_string_view<char, dummy_char_traits>;
  18. using string = std:: basic_string <char>;
  19. {
  20. string s{"QBCDE"};
  21. string_view sv1 ( s );
  22. assert ( sv1.size() == s.size());
  23. assert ( sv1.data() == s.data());
  24. }
  25. }