]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/optional/monadic/pr109242.cc
libstdc++: Remove dg-options "-std=gnu++23" from remaining tests
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / optional / monadic / pr109242.cc
CommitLineData
31a90971
JW
1// { dg-do compile { target c++23 } }
2
3#include <optional>
4
5// PR libstdc++/109242
6// transform omits required std::remove_cv_t from return optional type
7
8struct A { };
9struct B { };
10struct C { };
11struct D { };
12
13struct F
14{
15 const A operator()(int&);
16 const B operator()(const int&);
17 const C operator()(int&&);
18 const D operator()(const int&&);
19} f;
20
21std::optional<int> o;
22const auto& co = o;
23
24auto o1 = o.transform(f);
25static_assert(std::is_same_v<decltype(o1), std::optional<A>>);
26
27auto o2 = co.transform(f);
28static_assert(std::is_same_v<decltype(o2), std::optional<B>>);
29
30auto o3 = std::move(o).transform(f);
31static_assert(std::is_same_v<decltype(o3), std::optional<C>>);
32
33auto o4 = std::move(co).transform(f);
34static_assert(std::is_same_v<decltype(o4), std::optional<D>>);