54 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <utility>10 11// template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);12 13#include <utility>14#include <memory>15#include <cassert>16 17#include "test_macros.h"18 19int main(int, char**)20{21 {22 typedef std::pair<int, short> P1;23 P1 p1 = std::make_pair(3, static_cast<short>(4));24 assert(p1.first == 3);25 assert(p1.second == 4);26 }27 28#if TEST_STD_VER >= 1129 {30 typedef std::pair<std::unique_ptr<int>, short> P1;31 P1 p1 = std::make_pair(std::unique_ptr<int>(new int(3)), static_cast<short>(4));32 assert(*p1.first == 3);33 assert(p1.second == 4);34 }35 {36 typedef std::pair<std::unique_ptr<int>, short> P1;37 P1 p1 = std::make_pair(nullptr, static_cast<short>(4));38 assert(p1.first == nullptr);39 assert(p1.second == 4);40 }41#endif42#if TEST_STD_VER >= 1443 {44 typedef std::pair<int, short> P1;45 constexpr P1 p1 = std::make_pair(3, static_cast<short>(4));46 static_assert(p1.first == 3, "");47 static_assert(p1.second == 4, "");48 }49#endif50 51 52 return 0;53}54