operator_string.pass.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // UNSUPPORTED: c++98, c++03
  10. // <experimental/filesystem>
  11. // class path
  12. // operator string_type() const;
  13. #include "filesystem_include.hpp"
  14. #include <type_traits>
  15. #include <cassert>
  16. #include "test_macros.h"
  17. #include "filesystem_test_helper.hpp"
  18. int main()
  19. {
  20. using namespace fs;
  21. using string_type = path::string_type;
  22. const char* const value = "hello world";
  23. { // Check signature
  24. path p(value);
  25. static_assert(std::is_convertible<path, string_type>::value, "");
  26. static_assert(std::is_constructible<string_type, path>::value, "");
  27. ASSERT_SAME_TYPE(string_type, decltype(p.operator string_type()));
  28. ASSERT_NOT_NOEXCEPT(p.operator string_type());
  29. }
  30. {
  31. path p(value);
  32. assert(p.native() == value);
  33. string_type s = p;
  34. assert(s == value);
  35. assert(p == value);
  36. }
  37. }