operator_string.pass.cpp 1.2 KB

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