brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 0378e87 Raw
78 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// UNSUPPORTED: no-threads, c++0310 11// <future>12 13// class future<R>14 15// future& operator=(future&& rhs);16 17#include <future>18#include <cassert>19 20#include "test_macros.h"21 22int main(int, char**)23{24    {25        typedef int T;26        std::promise<T> p;27        std::future<T> f0 = p.get_future();28        std::future<T> f;29        f = std::move(f0);30        assert(!f0.valid());31        assert(f.valid());32    }33    {34        typedef int T;35        std::future<T> f0;36        std::future<T> f;37        f = std::move(f0);38        assert(!f0.valid());39        assert(!f.valid());40    }41    {42        typedef int& T;43        std::promise<T> p;44        std::future<T> f0 = p.get_future();45        std::future<T> f;46        f = std::move(f0);47        assert(!f0.valid());48        assert(f.valid());49    }50    {51        typedef int& T;52        std::future<T> f0;53        std::future<T> f;54        f = std::move(f0);55        assert(!f0.valid());56        assert(!f.valid());57    }58    {59        typedef void T;60        std::promise<T> p;61        std::future<T> f0 = p.get_future();62        std::future<T> f;63        f = std::move(f0);64        assert(!f0.valid());65        assert(f.valid());66    }67    {68        typedef void T;69        std::future<T> f0;70        std::future<T> f;71        f = std::move(f0);72        assert(!f0.valid());73        assert(!f.valid());74    }75 76  return 0;77}78