enum.perm_options.pass.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // enum class perm_options;
  12. #include "filesystem_include.hpp"
  13. #include <type_traits>
  14. #include <cassert>
  15. #include <sys/stat.h>
  16. #include "test_macros.h"
  17. #include "check_bitmask_types.hpp"
  18. constexpr fs::perm_options ME(int val) {
  19. return static_cast<fs::perm_options>(val);
  20. }
  21. int main() {
  22. typedef fs::perm_options E;
  23. static_assert(std::is_enum<E>::value, "");
  24. // Check that E is a scoped enum by checking for conversions.
  25. typedef std::underlying_type<E>::type UT;
  26. static_assert(!std::is_convertible<E, UT>::value, "");
  27. static_assert(std::is_same<UT, unsigned char >::value, ""); // Implementation detail
  28. typedef check_bitmask_type<E, E::replace, E::nofollow> BitmaskTester;
  29. assert(BitmaskTester::check());
  30. static_assert(
  31. E::replace == ME(1) &&
  32. E::add == ME(2) &&
  33. E::remove == ME(4) &&
  34. E::nofollow == ME(8),
  35. "Expected enumeration values do not match");
  36. }