Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
80
test/std/utilities/utility/forward/forward.pass.cpp
Normal file
80
test/std/utilities/utility/forward/forward.pass.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test forward
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
A source() {return A();}
|
||||
const A csource() {return A();}
|
||||
|
||||
typedef char one;
|
||||
struct two {one _[2];};
|
||||
struct four {one _[4];};
|
||||
struct eight {one _[8];};
|
||||
|
||||
one test(A&);
|
||||
two test(const A&);
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
four test(A&&);
|
||||
eight test(const A&&);
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
const A ca = A();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
|
||||
static_assert(sizeof(test(std::forward<A>(a))) == 4, "");
|
||||
static_assert(sizeof(test(std::forward<A>(source()))) == 4, "");
|
||||
|
||||
static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
|
||||
// static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
|
||||
static_assert(sizeof(test(std::forward<const A>(a))) == 8, "");
|
||||
static_assert(sizeof(test(std::forward<const A>(source()))) == 8, "");
|
||||
|
||||
static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
|
||||
// static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
|
||||
static_assert(sizeof(test(std::forward<const A>(ca))) == 8, "");
|
||||
static_assert(sizeof(test(std::forward<const A>(csource()))) == 8, "");
|
||||
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
|
||||
static_assert(sizeof(test(std::forward<A>(a))) == 1, "");
|
||||
// static_assert(sizeof(test(std::forward<A>(source()))) == 2, "");
|
||||
|
||||
static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
|
||||
static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
|
||||
static_assert(sizeof(test(std::forward<const A>(a))) == 2, "");
|
||||
static_assert(sizeof(test(std::forward<const A>(source()))) == 2, "");
|
||||
|
||||
static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
|
||||
static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
|
||||
static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
|
||||
static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
constexpr int i1 = std::move(23);
|
||||
static_assert(i1 == 23, "" );
|
||||
constexpr int i2 = std::forward<int>(42);
|
||||
static_assert(i2 == 42, "" );
|
||||
#endif
|
||||
}
|
||||
24
test/std/utilities/utility/forward/forward1.fail.cpp
Normal file
24
test/std/utilities/utility/forward/forward1.fail.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test forward
|
||||
|
||||
#include <utility>
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
A source() {return A();}
|
||||
const A csource() {return A();}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::forward<A&>(source()); // error
|
||||
}
|
||||
25
test/std/utilities/utility/forward/forward2.fail.cpp
Normal file
25
test/std/utilities/utility/forward/forward2.fail.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test forward
|
||||
|
||||
#include <utility>
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
A source() {return A();}
|
||||
const A csource() {return A();}
|
||||
|
||||
int main()
|
||||
{
|
||||
const A ca = A();
|
||||
std::forward<A&>(ca); // error
|
||||
}
|
||||
24
test/std/utilities/utility/forward/forward3.fail.cpp
Normal file
24
test/std/utilities/utility/forward/forward3.fail.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test forward
|
||||
|
||||
#include <utility>
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
A source() {return A();}
|
||||
const A csource() {return A();}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::forward<A&>(csource()); // error
|
||||
}
|
||||
25
test/std/utilities/utility/forward/forward4.fail.cpp
Normal file
25
test/std/utilities/utility/forward/forward4.fail.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test forward
|
||||
|
||||
#include <utility>
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
A source() {return A();}
|
||||
const A csource() {return A();}
|
||||
|
||||
int main()
|
||||
{
|
||||
const A ca = A();
|
||||
std::forward<A>(ca); // error
|
||||
}
|
||||
25
test/std/utilities/utility/forward/forward5.fail.cpp
Normal file
25
test/std/utilities/utility/forward/forward5.fail.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test forward
|
||||
|
||||
#include <utility>
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
A source() {return A();}
|
||||
const A csource() {return A();}
|
||||
|
||||
int main()
|
||||
{
|
||||
const A ca = A();
|
||||
std::forward<A>(csource()); // error
|
||||
}
|
||||
22
test/std/utilities/utility/forward/forward6.fail.cpp
Normal file
22
test/std/utilities/utility/forward/forward6.fail.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test forward
|
||||
|
||||
#include <utility>
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
std::forward(a); // error
|
||||
}
|
||||
71
test/std/utilities/utility/forward/move_copy.pass.cpp
Normal file
71
test/std/utilities/utility/forward/move_copy.pass.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
int copy_ctor = 0;
|
||||
int move_ctor = 0;
|
||||
|
||||
class A
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#else
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
A(const A&) {++copy_ctor;}
|
||||
A& operator=(const A&);
|
||||
|
||||
A(A&&) {++move_ctor;}
|
||||
A& operator=(A&&);
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
A(const A&) {++copy_ctor;}
|
||||
A& operator=(A&);
|
||||
|
||||
operator std::__rv<A> () {return std::__rv<A>(*this);}
|
||||
A(std::__rv<A>) {++move_ctor;}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
A() {}
|
||||
};
|
||||
|
||||
A source() {return A();}
|
||||
const A csource() {return A();}
|
||||
|
||||
void test(A) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
const A ca = A();
|
||||
|
||||
assert(copy_ctor == 0);
|
||||
assert(move_ctor == 0);
|
||||
|
||||
A a2 = a;
|
||||
assert(copy_ctor == 1);
|
||||
assert(move_ctor == 0);
|
||||
|
||||
A a3 = std::move(a);
|
||||
assert(copy_ctor == 1);
|
||||
assert(move_ctor == 1);
|
||||
|
||||
A a4 = ca;
|
||||
assert(copy_ctor == 2);
|
||||
assert(move_ctor == 1);
|
||||
|
||||
A a5 = std::move(ca);
|
||||
assert(copy_ctor == 3);
|
||||
assert(move_ctor == 1);
|
||||
}
|
||||
69
test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
Normal file
69
test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <utility>
|
||||
|
||||
// template <class T>
|
||||
// typename conditional
|
||||
// <
|
||||
// !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
|
||||
// const T&,
|
||||
// T&&
|
||||
// >::type
|
||||
// move_if_noexcept(T& x);
|
||||
|
||||
#include <utility>
|
||||
|
||||
class A
|
||||
{
|
||||
A(const A&);
|
||||
A& operator=(const A&);
|
||||
public:
|
||||
|
||||
A() {}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
A(A&&) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct legacy
|
||||
{
|
||||
legacy() {}
|
||||
legacy(const legacy&);
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
const int ci = 0;
|
||||
|
||||
legacy l;
|
||||
A a;
|
||||
const A ca;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(i)), int&&>::value), "");
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&&>::value), "");
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(a)), A&&>::value), "");
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&&>::value), "");
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int>::value), "");
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int>::value), "");
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A>::value), "");
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A>::value), "");
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
constexpr int i1 = 23;
|
||||
constexpr int i2 = std::move_if_noexcept(i1);
|
||||
static_assert(i2 == 23, "" );
|
||||
#endif
|
||||
|
||||
}
|
||||
49
test/std/utilities/utility/forward/move_only.pass.cpp
Normal file
49
test/std/utilities/utility/forward/move_only.pass.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
public:
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {return *this;}
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
move_only() {}
|
||||
};
|
||||
|
||||
move_only source() {return move_only();}
|
||||
const move_only csource() {return move_only();}
|
||||
|
||||
void test(move_only) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
move_only mo;
|
||||
|
||||
test(std::move(mo));
|
||||
test(source());
|
||||
}
|
||||
52
test/std/utilities/utility/forward/move_only1.fail.cpp
Normal file
52
test/std/utilities/utility/forward/move_only1.fail.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#include <typeinfo>
|
||||
#include <stdio.h>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
public:
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {}
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
move_only() {}
|
||||
};
|
||||
|
||||
move_only source() {return move_only();}
|
||||
const move_only csource() {return move_only();}
|
||||
|
||||
void test(move_only) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
move_only a;
|
||||
const move_only ca = move_only();
|
||||
|
||||
test(a);
|
||||
}
|
||||
52
test/std/utilities/utility/forward/move_only2.fail.cpp
Normal file
52
test/std/utilities/utility/forward/move_only2.fail.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#include <typeinfo>
|
||||
#include <stdio.h>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
public:
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {}
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
move_only() {}
|
||||
};
|
||||
|
||||
move_only source() {return move_only();}
|
||||
const move_only csource() {return move_only();}
|
||||
|
||||
void test(move_only) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
move_only a;
|
||||
const move_only ca = move_only();
|
||||
|
||||
test(ca);
|
||||
}
|
||||
49
test/std/utilities/utility/forward/move_only3.fail.cpp
Normal file
49
test/std/utilities/utility/forward/move_only3.fail.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
public:
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {}
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
move_only() {}
|
||||
};
|
||||
|
||||
move_only source() {return move_only();}
|
||||
const move_only csource() {return move_only();}
|
||||
|
||||
void test(move_only) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
move_only a;
|
||||
const move_only ca = move_only();
|
||||
|
||||
test(std::move(ca));
|
||||
}
|
||||
52
test/std/utilities/utility/forward/move_only4.fail.cpp
Normal file
52
test/std/utilities/utility/forward/move_only4.fail.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#include <typeinfo>
|
||||
#include <stdio.h>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
public:
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {}
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
move_only() {}
|
||||
};
|
||||
|
||||
move_only source() {return move_only();}
|
||||
const move_only csource() {return move_only();}
|
||||
|
||||
void test(move_only) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
move_only a;
|
||||
const move_only ca = move_only();
|
||||
|
||||
test(csource());
|
||||
}
|
||||
Reference in New Issue
Block a user