Index: include/type_traits =================================================================== --- include/type_traits +++ include/type_traits @@ -2155,7 +2155,7 @@ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename remove_reference<_Tp>::type&& move(_Tp&& __t) _NOEXCEPT { @@ -2164,7 +2164,7 @@ } template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&& forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT { @@ -2172,12 +2172,12 @@ } template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&& forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT { static_assert(!is_lvalue_reference<_Tp>::value, - "Can not forward an rvalue as an lvalue."); + "can not forward an rvalue as an lvalue"); return static_cast<_Tp&&>(__t); } Index: test/std/utilities/utility/forward/forward.fail.cpp =================================================================== --- /dev/null +++ test/std/utilities/utility/forward/forward.fail.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +#include "test_macros.h" + +struct A +{ +}; + +A source() {return A();} +const A csource() {return A();} + +int main() +{ +#if TEST_STD_VER >= 11 + { + std::forward(source()); // expected-note {{requested here}} + // expected-error@type_traits:* 1 {{static_assert failed "can not forward an rvalue as an lvalue"}} + } +#else + { + std::forward(source()); // expected-error {{no matching function for call to 'forward'}} + } +#endif + { + const A ca = A(); + std::forward(ca); // expected-error {{no matching function for call to 'forward'}} + } + { + std::forward(csource()); // expected-error {{no matching function for call to 'forward'}} + } + { + const A ca = A(); + std::forward(ca); // expected-error {{no matching function for call to 'forward'}} + } + { + std::forward(csource()); // expected-error {{no matching function for call to 'forward'}} + } + { + A a; + std::forward(a); // expected-error {{no matching function for call to 'forward'}} + } +} Index: test/std/utilities/utility/forward/forward.pass.cpp =================================================================== --- test/std/utilities/utility/forward/forward.pass.cpp +++ test/std/utilities/utility/forward/forward.pass.cpp @@ -7,32 +7,40 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // test forward #include +#include #include +#include "test_macros.h" + 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 +A source() noexcept {return A();} +const A csource() noexcept {return A();} + + +constexpr bool test_constexpr_forward() { +#if TEST_STD_VER > 11 + int x = 42; + const int cx = 101; + return std::forward(x) == 42 + && std::forward(x) == 42 + && std::forward(x) == 42 + && std::forward(x) == 42 + && std::forward(x) == 42 + && std::forward(x) == 42 + && std::forward(cx) == 101 + && std::forward(cx) == 101; +#else + return true; +#endif +} int main() { @@ -42,42 +50,42 @@ ((void)a); // Prevent unused warning ((void)ca); // Prevent unused warning -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - static_assert(sizeof(test(std::forward(a))) == 1, ""); - static_assert(sizeof(test(std::forward(a))) == 4, ""); - static_assert(sizeof(test(std::forward(source()))) == 4, ""); - - static_assert(sizeof(test(std::forward(a))) == 2, ""); -// static_assert(sizeof(test(std::forward(source()))) == 2, ""); - static_assert(sizeof(test(std::forward(a))) == 8, ""); - static_assert(sizeof(test(std::forward(source()))) == 8, ""); - - static_assert(sizeof(test(std::forward(ca))) == 2, ""); -// static_assert(sizeof(test(std::forward(csource()))) == 2, ""); - static_assert(sizeof(test(std::forward(ca))) == 8, ""); - static_assert(sizeof(test(std::forward(csource()))) == 8, ""); - -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - - static_assert(sizeof(test(std::forward(a))) == 1, ""); - static_assert(sizeof(test(std::forward(a))) == 1, ""); -// static_assert(sizeof(test(std::forward(source()))) == 2, ""); - - static_assert(sizeof(test(std::forward(a))) == 2, ""); - static_assert(sizeof(test(std::forward(source()))) == 2, ""); - static_assert(sizeof(test(std::forward(a))) == 2, ""); - static_assert(sizeof(test(std::forward(source()))) == 2, ""); - - static_assert(sizeof(test(std::forward(ca))) == 2, ""); - static_assert(sizeof(test(std::forward(csource()))) == 2, ""); - static_assert(sizeof(test(std::forward(ca))) == 2, ""); - static_assert(sizeof(test(std::forward(csource()))) == 2, ""); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -#if _LIBCPP_STD_VER > 11 - constexpr int i1 = std::move(23); - static_assert(i1 == 23, "" ); + static_assert(std::is_same(a)), A&>::value, ""); + static_assert(std::is_same(a)), A&&>::value, ""); + static_assert(std::is_same(source())), A&&>::value, ""); + static_assert(noexcept(std::forward(a)), ""); + static_assert(noexcept(std::forward(a)), ""); + static_assert(noexcept(std::forward(source())), ""); + + static_assert(std::is_same(a)), const A&>::value, ""); + static_assert(std::is_same(a)), const A&&>::value, ""); + static_assert(std::is_same(source())), const A&&>::value, ""); + static_assert(noexcept(std::forward(a)), ""); + static_assert(noexcept(std::forward(a)), ""); + static_assert(noexcept(std::forward(source())), ""); + + static_assert(std::is_same(ca)), const A&>::value, ""); + static_assert(std::is_same(ca)), const A&&>::value, ""); + static_assert(std::is_same(csource())), const A&&>::value, ""); + static_assert(noexcept(std::forward(ca)), ""); + static_assert(noexcept(std::forward(ca)), ""); + static_assert(noexcept(std::forward(csource())), ""); + +#if TEST_STD_VER > 11 + { + constexpr int i2 = std::forward(42); + static_assert(std::forward(42) == 42, ""); + static_assert(std::forward(i2) == 42, ""); + static_assert(test_constexpr_forward(), ""); + } +#endif +#if TEST_STD_VER == 11 && defined(_LIBCPP_VERSION) + // Test that std::forward is constexpr in C++11. This is an extension + // provided by both libc++ and libstdc++. + { constexpr int i2 = std::forward(42); - static_assert(i2 == 42, "" ); + static_assert(std::forward(42) == 42, "" ); + static_assert(std::forward(i2) == 42, ""); + } #endif } Index: test/std/utilities/utility/forward/forward1.fail.cpp =================================================================== --- test/std/utilities/utility/forward/forward1.fail.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -struct A -{ -}; - -A source() {return A();} -const A csource() {return A();} - -int main() -{ - std::forward(source()); // error -} Index: test/std/utilities/utility/forward/forward2.fail.cpp =================================================================== --- test/std/utilities/utility/forward/forward2.fail.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -struct A -{ -}; - -A source() {return A();} -const A csource() {return A();} - -int main() -{ - const A ca = A(); - std::forward(ca); // error -} Index: test/std/utilities/utility/forward/forward3.fail.cpp =================================================================== --- test/std/utilities/utility/forward/forward3.fail.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -struct A -{ -}; - -A source() {return A();} -const A csource() {return A();} - -int main() -{ - std::forward(csource()); // error -} Index: test/std/utilities/utility/forward/forward4.fail.cpp =================================================================== --- test/std/utilities/utility/forward/forward4.fail.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -struct A -{ -}; - -A source() {return A();} -const A csource() {return A();} - -int main() -{ - const A ca = A(); - std::forward(ca); // error -} Index: test/std/utilities/utility/forward/forward5.fail.cpp =================================================================== --- test/std/utilities/utility/forward/forward5.fail.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -struct A -{ -}; - -A source() {return A();} -const A csource() {return A();} - -int main() -{ - const A ca = A(); - std::forward(csource()); // error -} Index: test/std/utilities/utility/forward/forward6.fail.cpp =================================================================== --- test/std/utilities/utility/forward/forward6.fail.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -struct A -{ -}; - -int main() -{ - A a; - std::forward(a); // error -} Index: test/std/utilities/utility/forward/forward_03.pass.cpp =================================================================== --- /dev/null +++ test/std/utilities/utility/forward/forward_03.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#include + +#include "test_macros.h" + +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&); + +int main() +{ + A a; + const A ca = A(); + + ((void)a); // Prevent unused warning + ((void)ca); // Prevent unused warning + +#if TEST_STD_VER < 11 + static_assert(sizeof(test(std::forward(a))) == 1, ""); + static_assert(sizeof(test(std::forward(a))) == 1, ""); + + // Libc++'s C++03 implementation of 'forward' cannot accept true non-const + // rvalues. + // static_assert(sizeof(test(std::forward(source()))) == 2, ""); + + static_assert(sizeof(test(std::forward(a))) == 2, ""); + static_assert(sizeof(test(std::forward(source()))) == 2, ""); + static_assert(sizeof(test(std::forward(a))) == 2, ""); + static_assert(sizeof(test(std::forward(source()))) == 2, ""); + + static_assert(sizeof(test(std::forward(ca))) == 2, ""); + static_assert(sizeof(test(std::forward(csource()))) == 2, ""); + static_assert(sizeof(test(std::forward(ca))) == 2, ""); + static_assert(sizeof(test(std::forward(csource()))) == 2, ""); +#endif +} Index: test/std/utilities/utility/forward/move.fail.cpp =================================================================== --- /dev/null +++ test/std/utilities/utility/forward/move.fail.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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: c++98, c++03 + +// test move + +#include +#include + +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() +{ + move_only a; + const move_only ca = move_only(); + + test(std::move(ca)); // c +} Index: test/std/utilities/utility/forward/move.pass.cpp =================================================================== --- /dev/null +++ test/std/utilities/utility/forward/move.pass.cpp @@ -0,0 +1,121 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +#include "test_macros.h" + +class move_only +{ + move_only(const move_only&); + move_only& operator=(const move_only&); +public: + move_only(move_only&&) {} + move_only& operator=(move_only&&) {return *this;} + + move_only() {} +}; + +move_only source() {return move_only();} +const move_only csource() {return move_only();} + +void test(move_only) {} + +int x = 42; +const int& cx = x; + +template +QualInt get() noexcept { return static_cast(x); } + + +int copy_ctor = 0; +int move_ctor = 0; + +struct A { + A() {} + A(const A&) {++copy_ctor;} + A(A&&) {++move_ctor;} + A& operator=(const A&) = delete; +}; + +constexpr bool test_constexpr_move() { +#if TEST_STD_VER > 11 + int x = 42; + const int cx = x; + return std::move(x) == 42 + && std::move(cx) == 42 + && std::move(static_cast(x)) == 42 + && std::move(static_cast(x)) == 42; +#else + return true; +#endif +} + +int main() +{ + { // Test return type and noexcept. + static_assert(std::is_same::value, ""); + static_assert(noexcept(std::move(x)), ""); + static_assert(std::is_same::value, ""); + static_assert(noexcept(std::move(cx)), ""); + static_assert(std::is_same::value, ""); + static_assert(noexcept(std::move(42)), ""); + static_assert(std::is_same())), const int&&>::value, ""); + static_assert(noexcept(std::move(get())), ""); + } + { // test copy and move semantics + 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); + } + { // test on a move only type + move_only mo; + test(std::move(mo)); + test(source()); + } +#if TEST_STD_VER > 11 + { + constexpr int x = 42; + static_assert(std::move(x) == 42, ""); + static_assert(test_constexpr_move(), ""); + } +#endif +#if TEST_STD_VER == 11 && defined(_LIBCPP_VERSION) + // Test that std::forward is constexpr in C++11. This is an extension + // provided by both libc++ and libstdc++. + { + constexpr int x = 42; + static_assert(std::move(x) == 42, ""); + } +#endif +} Index: test/std/utilities/utility/forward/move_copy.pass.cpp =================================================================== --- test/std/utilities/utility/forward/move_copy.pass.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -// UNSUPPORTED: c++98, c++03 - -#include -#include - -int copy_ctor = 0; -int move_ctor = 0; - -class A -{ -public: - - A(const A&) {++copy_ctor;} - A& operator=(const A&); - - A(A&&) {++move_ctor;} - A& operator=(A&&); - - 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); -} Index: test/std/utilities/utility/forward/move_only.pass.cpp =================================================================== --- test/std/utilities/utility/forward/move_only.pass.cpp +++ /dev/null @@ -1,39 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -// UNSUPPORTED: c++98, c++03 - -#include -#include - -class move_only -{ - move_only(const move_only&); - move_only& operator=(const move_only&); -public: - move_only(move_only&&) {} - move_only& operator=(move_only&&) {return *this;} - - 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()); -} Index: test/std/utilities/utility/forward/move_only1.fail.cpp =================================================================== --- test/std/utilities/utility/forward/move_only1.fail.cpp +++ /dev/null @@ -1,52 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -#include - -#include -#include - -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 () {return std::__rv(*this);} - move_only(std::__rv) {} -#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); -} Index: test/std/utilities/utility/forward/move_only2.fail.cpp =================================================================== --- test/std/utilities/utility/forward/move_only2.fail.cpp +++ /dev/null @@ -1,52 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -#include - -#include -#include - -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 () {return std::__rv(*this);} - move_only(std::__rv) {} -#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); -} Index: test/std/utilities/utility/forward/move_only3.fail.cpp =================================================================== --- test/std/utilities/utility/forward/move_only3.fail.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -#include - -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 () {return std::__rv(*this);} - move_only(std::__rv) {} -#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)); -} Index: test/std/utilities/utility/forward/move_only4.fail.cpp =================================================================== --- test/std/utilities/utility/forward/move_only4.fail.cpp +++ /dev/null @@ -1,52 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -#include - -#include -#include - -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 () {return std::__rv(*this);} - move_only(std::__rv) {} -#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()); -}