Files
libcxx/test/std/utilities/utility/forward/move.fail.cpp
Eric Fiselier 3f10018902 Make move and forward work in C++03.
These functions are key to allowing the use of rvalues and variadics
in C++03 mode. Everything works the same as in C++11, except for one
tangentially related case:

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

In C++11, T has a deleted copy constructor. But in C++03 Clang gives
it both a move and a copy constructor. This seems reasonable enough
given the extensions it's using.

The other changes in this patch were the minimal set required
to keep the tests passing after the move/forward change. Most notably
the removal of the `__rv<unique_ptr>` hack that was present
in an attempt to make unique_ptr move only without language support.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@364063 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-21 15:20:55 +00:00

39 lines
1.0 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// This test should pass in C++03 with Clang extensions because Clang does
// not implicitly delete the copy constructor when move constructors are
// defaulted using extensions.
// XFAIL: c++98, c++03
// test move
#include <utility>
#include <cassert>
struct move_only {
move_only() {}
move_only(move_only&&) = default;
move_only& operator=(move_only&&) = default;
};
move_only source() {return move_only();}
const move_only csource() {return move_only();}
void test(move_only) {}
int main(int, char**)
{
const move_only ca = move_only();
// expected-error@+1 {{call to implicitly-deleted copy constructor of 'move_only'}}
test(std::move(ca));
return 0;
}