]>
Commit | Line | Data |
---|---|---|
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 | ||
8 | struct A { }; | |
9 | struct B { }; | |
10 | struct C { }; | |
11 | struct D { }; | |
12 | ||
13 | struct 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 | ||
21 | std::optional<int> o; | |
22 | const auto& co = o; | |
23 | ||
24 | auto o1 = o.transform(f); | |
25 | static_assert(std::is_same_v<decltype(o1), std::optional<A>>); | |
26 | ||
27 | auto o2 = co.transform(f); | |
28 | static_assert(std::is_same_v<decltype(o2), std::optional<B>>); | |
29 | ||
30 | auto o3 = std::move(o).transform(f); | |
31 | static_assert(std::is_same_v<decltype(o3), std::optional<C>>); | |
32 | ||
33 | auto o4 = std::move(co).transform(f); | |
34 | static_assert(std::is_same_v<decltype(o4), std::optional<D>>); |