15a83710eSEric Fiselier //===----------------------------------------------------------------------===// 25a83710eSEric Fiselier // 357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65a83710eSEric Fiselier // 75a83710eSEric Fiselier //===----------------------------------------------------------------------===// 85a83710eSEric Fiselier 95a83710eSEric Fiselier // <functional> 105a83710eSEric Fiselier 115a83710eSEric Fiselier // reference_wrapper 125a83710eSEric Fiselier 135a83710eSEric Fiselier // template <ObjectType T> reference_wrapper<const T> cref(reference_wrapper<T> t); 145a83710eSEric Fiselier 155a83710eSEric Fiselier #include <functional> 165a83710eSEric Fiselier #include <cassert> 175a83710eSEric Fiselier 187fc6a556SMarshall Clow #include "test_macros.h" 197fc6a556SMarshall Clow 20e442f383SLogan Smith namespace adl { 21e442f383SLogan Smith struct A {}; cref(A)22e442f383SLogan Smith void cref(A) {} 23e442f383SLogan Smith } 24e442f383SLogan Smith test()25*a13c1058SArthur O'DwyerTEST_CONSTEXPR_CXX20 bool test() 26*a13c1058SArthur O'Dwyer { 275a83710eSEric Fiselier { 285a83710eSEric Fiselier const int i = 0; 295a83710eSEric Fiselier std::reference_wrapper<const int> r1 = std::cref(i); 305a83710eSEric Fiselier std::reference_wrapper<const int> r2 = std::cref(r1); 315a83710eSEric Fiselier assert(&r2.get() == &i); 32*a13c1058SArthur O'Dwyer } 33e442f383SLogan Smith { 34e442f383SLogan Smith adl::A a; 35e442f383SLogan Smith std::reference_wrapper<const adl::A> a1 = std::cref(a); 36e442f383SLogan Smith std::reference_wrapper<const adl::A> a2 = std::cref(a1); 37e442f383SLogan Smith assert(&a2.get() == &a); 38e442f383SLogan Smith } 39*a13c1058SArthur O'Dwyer return true; 40*a13c1058SArthur O'Dwyer } 41*a13c1058SArthur O'Dwyer main(int,char **)42*a13c1058SArthur O'Dwyerint main(int, char**) 43*a13c1058SArthur O'Dwyer { 44*a13c1058SArthur O'Dwyer test(); 45*a13c1058SArthur O'Dwyer #if TEST_STD_VER > 17 46*a13c1058SArthur O'Dwyer static_assert(test()); 47*a13c1058SArthur O'Dwyer #endif 48e442f383SLogan Smith 492df59c50SJF Bastien return 0; 505a83710eSEric Fiselier } 51