default.pass.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. // <utility>
  10. // template <class T1, class T2> struct pair
  11. // constexpr pair();
  12. // This test doesn't pass due to a constexpr bug in GCC 4.9 that fails
  13. // to initialize any type without a user provided constructor in a constant
  14. // expression (e.g. float).
  15. // XFAIL: gcc-4.9
  16. // NOTE: The SFINAE on the default constructor is tested in
  17. // default-sfinae.pass.cpp
  18. #include <utility>
  19. #include <type_traits>
  20. #include <cassert>
  21. #include "test_macros.h"
  22. #include "archetypes.hpp"
  23. int main()
  24. {
  25. {
  26. typedef std::pair<float, short*> P;
  27. P p;
  28. assert(p.first == 0.0f);
  29. assert(p.second == nullptr);
  30. }
  31. #if TEST_STD_VER >= 11
  32. {
  33. typedef std::pair<float, short*> P;
  34. constexpr P p;
  35. static_assert(p.first == 0.0f, "");
  36. static_assert(p.second == nullptr, "");
  37. }
  38. {
  39. using NoDefault = ImplicitTypes::NoDefault;
  40. using P = std::pair<int, NoDefault>;
  41. static_assert(!std::is_default_constructible<P>::value, "");
  42. using P2 = std::pair<NoDefault, int>;
  43. static_assert(!std::is_default_constructible<P>::value, "");
  44. }
  45. #endif
  46. }