From beb6efb42eca21ef5b9d1cf616558dfb991186c7 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Mon, 1 Apr 2019 19:53:44 +0000 Subject: [libcxx] Make sure reference_wrapper works with incomplete types Summary: Completes P0357R3, which was merged into the C++20 Working Draft in San Diego. Reviewers: EricWF, mclow.lists Subscribers: christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D54722 llvm-svn: 357423 --- .../refwrap.helpers/ref.incomplete.pass.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref.incomplete.pass.cpp (limited to 'libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref.incomplete.pass.cpp') diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref.incomplete.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref.incomplete.pass.cpp new file mode 100644 index 00000000000..d5c26b274a4 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref.incomplete.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// +// +// reference_wrapper +// +// template reference_wrapper ref(T& t); +// +// where T is an incomplete type (since C++20) + +#include +#include + + +struct Foo; + +Foo& get_foo(); + +void test() { + Foo& foo = get_foo(); + std::reference_wrapper ref = std::ref(foo); + assert(&ref.get() == &foo); +} + +struct Foo { }; + +Foo& get_foo() { + static Foo foo; + return foo; +} + +int main() { + test(); +} -- cgit v1.2.3