constexpr_init.pass.cpp 1.1 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, c++11
  10. // XFAIL: gcc-7, gcc-8
  11. // <functional>
  12. // equal_to, not_equal_to, less, et al.
  13. // Test that these types can be constructed w/o an initializer in a constexpr
  14. // context. This is specifically testing gcc.gnu.org/PR83921
  15. #include <functional>
  16. #include "test_macros.h"
  17. template <class T>
  18. constexpr bool test_constexpr_context() {
  19. std::equal_to<T> eq;
  20. ((void)eq);
  21. std::not_equal_to<T> neq;
  22. ((void)neq);
  23. std::less<T> l;
  24. ((void)l);
  25. std::less_equal<T> le;
  26. ((void)le);
  27. std::greater<T> g;
  28. ((void)g);
  29. std::greater_equal<T> ge;
  30. ((void)ge);
  31. return true;
  32. }
  33. static_assert(test_constexpr_context<int>(), "");
  34. static_assert(test_constexpr_context<void>(), "");
  35. int main() {
  36. }