summaryrefslogtreecommitdiffstats
path: root/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
blob: f13ca92e280729f870f115e5b6126df11587919f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//===----------------------------------------------------------------------===//
//
//                     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, c++11, c++14

// <optional>

// optional(optional<T>&& rhs);

#include <optional>
#include <string>
#include <type_traits>
#include <utility>

using std::optional;

struct X {};

struct Y
{
    Y() = default;
    Y(Y&&) {}
};

struct Z
{
    Z() = default;
    Z(Z&&) = delete;
    Z(const Z&) = delete;
    Z& operator=(Z&&) = delete;
    Z& operator=(const Z&) = delete;
};

int main()
{
    {
        using T = int;
        static_assert((std::is_trivially_copy_constructible<optional<T>>::value), "");
        constexpr optional<T> opt;
        constexpr optional<T> opt2 = std::move(opt);
        (void)opt2;
    }
    {
        using T = X;
        static_assert((std::is_trivially_copy_constructible<optional<T>>::value), "");
        constexpr optional<T> opt;
        constexpr optional<T> opt2 = std::move(opt);
        (void)opt2;
    }
    static_assert(!(std::is_trivially_move_constructible<optional<Y>>::value), "");
    static_assert(!(std::is_trivially_move_constructible<optional<std::string>>::value), "");

    static_assert(!(std::is_move_constructible<optional<Z>>::value), "");
}
OpenPOWER on IntegriCloud