mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 20:29:39 +08:00
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
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
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.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// UNSUPPORTED: c++98, c++03
|
|
|
|
// <utility>
|
|
|
|
// template <class T1, class T2> struct pair
|
|
|
|
// pair(pair&&) = default;
|
|
|
|
#include <utility>
|
|
#include <memory>
|
|
#include <cassert>
|
|
|
|
#include "test_macros.h"
|
|
|
|
struct Dummy {
|
|
Dummy(Dummy const&) = delete;
|
|
Dummy(Dummy &&) = default;
|
|
};
|
|
|
|
int main()
|
|
{
|
|
{
|
|
typedef std::pair<int, short> P1;
|
|
static_assert(std::is_move_constructible<P1>::value, "");
|
|
P1 p1(3, static_cast<short>(4));
|
|
P1 p2 = std::move(p1);
|
|
assert(p2.first == 3);
|
|
assert(p2.second == 4);
|
|
}
|
|
{
|
|
using P = std::pair<Dummy, int>;
|
|
static_assert(!std::is_copy_constructible<P>::value, "");
|
|
static_assert(std::is_move_constructible<P>::value, "");
|
|
}
|
|
}
|