libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
73
test/utilities/utility/forward/forward.pass.cpp
Normal file
73
test/utilities/utility/forward/forward.pass.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. 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&);
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
four test(A&&);
|
||||
eight test(const A&&);
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
const A ca = A();
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
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
|
||||
|
||||
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
|
||||
}
|
24
test/utilities/utility/forward/forward1.fail.cpp
Normal file
24
test/utilities/utility/forward/forward1.fail.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. 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/utilities/utility/forward/forward2.fail.cpp
Normal file
25
test/utilities/utility/forward/forward2.fail.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. 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/utilities/utility/forward/forward3.fail.cpp
Normal file
24
test/utilities/utility/forward/forward3.fail.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. 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/utilities/utility/forward/forward4.fail.cpp
Normal file
25
test/utilities/utility/forward/forward4.fail.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. 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/utilities/utility/forward/forward5.fail.cpp
Normal file
25
test/utilities/utility/forward/forward5.fail.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. 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/utilities/utility/forward/forward6.fail.cpp
Normal file
22
test/utilities/utility/forward/forward6.fail.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test forward
|
||||
|
||||
#include <utility>
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
std::forward(a); // error
|
||||
}
|
71
test/utilities/utility/forward/move_copy.pass.cpp
Normal file
71
test/utilities/utility/forward/move_copy.pass.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
int copy_ctor = 0;
|
||||
int move_ctor = 0;
|
||||
|
||||
class A
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
#else
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
A(const A&) {++copy_ctor;}
|
||||
A& operator=(const A&);
|
||||
|
||||
A(A&&) {++move_ctor;}
|
||||
A& operator=(A&&);
|
||||
#else
|
||||
A(const A&) {++copy_ctor;}
|
||||
A& operator=(A&);
|
||||
|
||||
operator std::__rv<A> () {return std::__rv<A>(*this);}
|
||||
A(std::__rv<A>) {++move_ctor;}
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
55
test/utilities/utility/forward/move_if_noexcept.pass.cpp
Normal file
55
test/utilities/utility/forward/move_if_noexcept.pass.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <utility>
|
||||
|
||||
// template <class T>
|
||||
// typename conditional
|
||||
// <
|
||||
// !has_nothrow_move_constructor<T>::value && has_copy_constructor<T>::value,
|
||||
// const T&,
|
||||
// T&&
|
||||
// >::type
|
||||
// move_if_noexcept(T& x);
|
||||
|
||||
#include <utility>
|
||||
|
||||
class A
|
||||
{
|
||||
A(const A&);
|
||||
A& operator=(const A&);
|
||||
public:
|
||||
|
||||
A() {}
|
||||
#ifdef _LIBCPP_MOVE
|
||||
A(A&&) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
const int ci = 0;
|
||||
|
||||
A a;
|
||||
const A ca;
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
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)), const A&>::value), "");
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&>::value), "");
|
||||
#else
|
||||
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
|
||||
|
||||
}
|
49
test/utilities/utility/forward/move_only.pass.cpp
Normal file
49
test/utilities/utility/forward/move_only.pass.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {}
|
||||
#else
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif
|
||||
|
||||
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/utilities/utility/forward/move_only1.fail.cpp
Normal file
52
test/utilities/utility/forward/move_only1.fail.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#include <typeinfo>
|
||||
#include <stdio.h>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {}
|
||||
#else
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif
|
||||
|
||||
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/utilities/utility/forward/move_only2.fail.cpp
Normal file
52
test/utilities/utility/forward/move_only2.fail.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#include <typeinfo>
|
||||
#include <stdio.h>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {}
|
||||
#else
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif
|
||||
|
||||
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/utilities/utility/forward/move_only3.fail.cpp
Normal file
49
test/utilities/utility/forward/move_only3.fail.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {}
|
||||
#else
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif
|
||||
|
||||
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/utilities/utility/forward/move_only4.fail.cpp
Normal file
52
test/utilities/utility/forward/move_only4.fail.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test move
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#include <typeinfo>
|
||||
#include <stdio.h>
|
||||
|
||||
class move_only
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(const move_only&);
|
||||
move_only& operator=(const move_only&);
|
||||
#else
|
||||
move_only(move_only&);
|
||||
move_only& operator=(move_only&);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
move_only(move_only&&) {}
|
||||
move_only& operator=(move_only&&) {}
|
||||
#else
|
||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
||||
move_only(std::__rv<move_only>) {}
|
||||
#endif
|
||||
|
||||
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