//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 // // template struct pair // pair(const T1& x, const T2& y); #include #include #include "archetypes.hpp" #include "test_convertible.hpp" using namespace ImplicitTypes; // Get implicitly archetypes struct ExplicitT { constexpr explicit ExplicitT(int x) : value(x) {} constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {} int value; }; struct ImplicitT { constexpr ImplicitT(int x) : value(x) {} constexpr ImplicitT(ImplicitT const& o) : value(o.value) {} int value; }; template void test_sfinae() { using P1 = std::pair; using P2 = std::pair; using T1Arg = T1 const&; using T2 = int const&; static_assert(std::is_constructible::value == CanCopy, ""); static_assert(test_convertible() == CanConvert, ""); static_assert(std::is_constructible::value == CanCopy, ""); static_assert(test_convertible() == CanConvert, ""); } int main() { { typedef std::pair P; P p(3.5f, 0); assert(p.first == 3.5f); assert(p.second == nullptr); } { typedef std::pair P; P p(1, 2); assert(p.first.value == 1); assert(p.second == 2); } { test_sfinae(); test_sfinae(); test_sfinae(); test_sfinae(); test_sfinae(); test_sfinae(); test_sfinae(); test_sfinae(); } #if TEST_STD_VER > 11 { typedef std::pair P; constexpr P p(3.5f, 0); static_assert(p.first == 3.5f, ""); static_assert(p.second == nullptr, ""); } { using P = std::pair; constexpr ExplicitT e(42); constexpr int x = 10; constexpr P p(e, x); static_assert(p.first.value == 42, ""); static_assert(p.second == 10, ""); } { using P = std::pair; constexpr ImplicitT e(42); constexpr int x = 10; constexpr P p = {e, x}; static_assert(p.first.value == 42, ""); static_assert(p.second == 10, ""); } #endif }