operator_string.pass.cpp 1.2 KB

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