align_val_t.pass.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. // enum class align_val_t : size_t {}
  9. // UNSUPPORTED: c++98, c++03, c++11, c++14
  10. #include <new>
  11. #include "test_macros.h"
  12. int main(int, char**) {
  13. {
  14. static_assert(std::is_enum<std::align_val_t>::value, "");
  15. static_assert(std::is_same<std::underlying_type<std::align_val_t>::type, std::size_t>::value, "");
  16. static_assert(!std::is_constructible<std::align_val_t, std::size_t>::value, "");
  17. static_assert(!std::is_constructible<std::size_t, std::align_val_t>::value, "");
  18. }
  19. {
  20. constexpr auto a = std::align_val_t(0);
  21. constexpr auto b = std::align_val_t(32);
  22. constexpr auto c = std::align_val_t(-1);
  23. static_assert(a != b, "");
  24. static_assert(a == std::align_val_t(0), "");
  25. static_assert(b == std::align_val_t(32), "");
  26. static_assert(static_cast<std::size_t>(c) == (std::size_t)-1, "");
  27. }
  28. return 0;
  29. }