xref: /llvm-project/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp (revision 048688fd80fadce1c72c365b0d74599a33389cfb)
1eec04092SArthur O'Dwyer //===----------------------------------------------------------------------===//
2eec04092SArthur O'Dwyer //
3eec04092SArthur O'Dwyer // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4eec04092SArthur O'Dwyer // See https://llvm.org/LICENSE.txt for license information.
5eec04092SArthur O'Dwyer // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6eec04092SArthur O'Dwyer //
7eec04092SArthur O'Dwyer //===----------------------------------------------------------------------===//
8eec04092SArthur O'Dwyer 
9eec04092SArthur O'Dwyer // UNSUPPORTED: c++03, c++11, c++14
10eec04092SArthur O'Dwyer 
11eec04092SArthur O'Dwyer // <functional>
12eec04092SArthur O'Dwyer 
13eec04092SArthur O'Dwyer // template <class T>
14eec04092SArthur O'Dwyer //   reference_wrapper(T&) -> reference_wrapper<T>;
15eec04092SArthur O'Dwyer 
16eec04092SArthur O'Dwyer #include <functional>
17eec04092SArthur O'Dwyer 
main(int,char **)18*048688fdSLouis Dionne int main(int, char**) {
19eec04092SArthur O'Dwyer     int i = 0;
20eec04092SArthur O'Dwyer     std::reference_wrapper ri(i);
21eec04092SArthur O'Dwyer     static_assert(std::is_same_v<decltype(ri), std::reference_wrapper<int>>);
22eec04092SArthur O'Dwyer     std::reference_wrapper ri2(ri);
23eec04092SArthur O'Dwyer     static_assert(std::is_same_v<decltype(ri2), std::reference_wrapper<int>>);
24eec04092SArthur O'Dwyer     const int j = 0;
25eec04092SArthur O'Dwyer     std::reference_wrapper rj(j);
26eec04092SArthur O'Dwyer     static_assert(std::is_same_v<decltype(rj), std::reference_wrapper<const int>>);
27eec04092SArthur O'Dwyer     std::reference_wrapper rj2(rj);
28eec04092SArthur O'Dwyer     static_assert(std::is_same_v<decltype(rj2), std::reference_wrapper<const int>>);
29*048688fdSLouis Dionne 
30*048688fdSLouis Dionne     return 0;
31eec04092SArthur O'Dwyer }
32