<commit_before>//===----------------------------------------------------------------------===//
//
//                     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: libcpp-has-no-threads
// UNSUPPORTED: c++98, c++03

// <future>

// class future<R>

// shared_future<R> share() &&;

#include <future>
#include <cassert>

int main()
{
    {
        typedef int T;
        std::promise<T> p;
        std::future<T> f0 = p.get_future();
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = std::move(f0.share());
        assert(!f0.valid());
        assert(f.valid());
    }
    {
        typedef int T;
        std::future<T> f0;
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = std::move(f0.share());
        assert(!f0.valid());
        assert(!f.valid());
    }
    {
        typedef int& T;
        std::promise<T> p;
        std::future<T> f0 = p.get_future();
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = std::move(f0.share());
        assert(!f0.valid());
        assert(f.valid());
    }
    {
        typedef int& T;
        std::future<T> f0;
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = std::move(f0.share());
        assert(!f0.valid());
        assert(!f.valid());
    }
    {
        typedef void T;
        std::promise<T> p;
        std::future<T> f0 = p.get_future();
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = std::move(f0.share());
        assert(!f0.valid());
        assert(f.valid());
    }
    {
        typedef void T;
        std::future<T> f0;
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = std::move(f0.share());
        assert(!f0.valid());
        assert(!f.valid());
    }
}
<commit_msg>[libcxx] [test] Fix Clang -Wpessimizing-move "moving a temporary object prevents copy elision".<commit_after>//===----------------------------------------------------------------------===//
//
//                     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: libcpp-has-no-threads
// UNSUPPORTED: c++98, c++03

// <future>

// class future<R>

// shared_future<R> share() &&;

#include <future>
#include <cassert>

int main()
{
    {
        typedef int T;
        std::promise<T> p;
        std::future<T> f0 = p.get_future();
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = f0.share();
        assert(!f0.valid());
        assert(f.valid());
    }
    {
        typedef int T;
        std::future<T> f0;
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = f0.share();
        assert(!f0.valid());
        assert(!f.valid());
    }
    {
        typedef int& T;
        std::promise<T> p;
        std::future<T> f0 = p.get_future();
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = f0.share();
        assert(!f0.valid());
        assert(f.valid());
    }
    {
        typedef int& T;
        std::future<T> f0;
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = f0.share();
        assert(!f0.valid());
        assert(!f.valid());
    }
    {
        typedef void T;
        std::promise<T> p;
        std::future<T> f0 = p.get_future();
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = f0.share();
        assert(!f0.valid());
        assert(f.valid());
    }
    {
        typedef void T;
        std::future<T> f0;
        static_assert( noexcept(f0.share()), "");
        std::shared_future<T> f = f0.share();
        assert(!f0.valid());
        assert(!f.valid());
    }
}

{'fraction_non_alphanumeric': 0.24903381642512076, 'fraction_numerical': 0.01352657004830918, 'mean_word_length': 1.7154098360655738, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4738713', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1328, 'n_words': 255}