1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
15 #include "test_macros.h"
21 A source() {return A();}
22 const A csource() {return A();}
25 struct two {one _[2];};
26 struct four {one _[4];};
27 struct eight {one _[8];};
37 ((void)a); // Prevent unused warning
38 ((void)ca); // Prevent unused warning
41 static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
42 static_assert(sizeof(test(std::forward<A>(a))) == 1, "");
44 // Libc++'s C++03 implementation of 'forward' cannot accept true non-const
46 // static_assert(sizeof(test(std::forward<A>(source()))) == 2, "");
48 static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
49 static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
50 static_assert(sizeof(test(std::forward<const A>(a))) == 2, "");
51 static_assert(sizeof(test(std::forward<const A>(source()))) == 2, "");
53 static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
54 static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
55 static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
56 static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");