Files
libcxx/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
Stephan T. Lavavej f008c5389e [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.
Add static_cast<short> when constructing pair<Whatever, short> from (Something, int).

Fixes D27540.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289107 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 21:38:14 +00:00

40 lines
957 B
C++

//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// pair(const pair&) = default;
#include <utility>
#include <cassert>
#include "test_macros.h"
int main()
{
{
typedef std::pair<int, short> P1;
P1 p1(3, static_cast<short>(4));
P1 p2 = p1;
assert(p2.first == 3);
assert(p2.second == 4);
}
#if TEST_STD_VER > 11
{
typedef std::pair<int, short> P1;
constexpr P1 p1(3, static_cast<short>(4));
constexpr P1 p2 = p1;
static_assert(p2.first == 3, "");
static_assert(p2.second == 4, "");
}
#endif
}