示例#1
0
int main()
{
    move_only a;
    const move_only ca = move_only();

    test(std::move(ca));
}
int main()
{
    move_only a;
    const move_only ca = move_only();

    test(a);
}
int main() {
    X x;
    auto f0 = std::async(&X::foo, &x, 42, "hello");
    auto f1 = std::async(&X::bar, x, "goodbye");
    f0.get();
    f1.get();

    auto f2 = std::async(baz, std::ref(x));
    f2.get();

    Y y;
    auto f3 = std::async(Y(), 3.141);
    auto f4 = std::async(std::ref(y), 2.718);
    f3.get();
    f4.get();

    auto f5 = std::async(move_only());
    f5.get();

    auto f6 = std::async(std::launch::async, Y(), 1.2);

    X another_x;
    auto f7 = std::async(std::launch::deferred, baz, 
            std::ref(another_x));

    X yet_another_x;
    auto f8 = std::async(
            std::launch::deferred | std::launch::async,
            baz, std::ref(yet_another_x));

    X the_last_x;
    auto f9 = std::async(baz, std::ref(the_last_x));

    f7.wait();


    return 0;
}
示例#4
0
文件: elision_neg.C 项目: 0day-ci/gcc
int main()
{
    move_only t1 = test1();
    move_only t2 = test2(move_only());
    return 0;
}
示例#5
0
const move_only csource() {return move_only();}
示例#6
0
move_only source() {return move_only();}
示例#7
0
int main()
{
    {
    std::allocator<A> a;
    assert(new_called == 0);
    assert(A_constructed == 0);

    A* ap = a.allocate(3);
    assert(new_called == 1);
    assert(A_constructed == 0);

    a.construct(ap);
    assert(new_called == 1);
    assert(A_constructed == 1);

    a.destroy(ap);
    assert(new_called == 1);
    assert(A_constructed == 0);

    a.construct(ap, A());
    assert(new_called == 1);
    assert(A_constructed == 1);

    a.destroy(ap);
    assert(new_called == 1);
    assert(A_constructed == 0);

    a.construct(ap, 5);
    assert(new_called == 1);
    assert(A_constructed == 1);

    a.destroy(ap);
    assert(new_called == 1);
    assert(A_constructed == 0);

    a.construct(ap, 5, (int*)0);
    assert(new_called == 1);
    assert(A_constructed == 1);

    a.destroy(ap);
    assert(new_called == 1);
    assert(A_constructed == 0);

    a.deallocate(ap, 3);
    assert(new_called == 0);
    assert(A_constructed == 0);
    }
    {
    std::allocator<move_only> a;
    assert(new_called == 0);
    assert(move_only_constructed == 0);

    move_only* ap = a.allocate(3);
    assert(new_called == 1);
    assert(move_only_constructed == 0);

    a.construct(ap);
    assert(new_called == 1);
    assert(move_only_constructed == 1);

    a.destroy(ap);
    assert(new_called == 1);
    assert(move_only_constructed == 0);

    a.construct(ap, move_only());
    assert(new_called == 1);
    assert(move_only_constructed == 1);

    a.destroy(ap);
    assert(new_called == 1);
    assert(move_only_constructed == 0);

    a.deallocate(ap, 3);
    assert(new_called == 0);
    assert(move_only_constructed == 0);
    }
}
void
test4(bool b)
{
    if (!b)
        throw move_only();
}
move_only
test1()
{
    return move_only();
}