brintos

brintos / llvm-project-archived public Read only

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