Does this cause fu to have different types depending on the value of b? ie if b then fu is a copy of foo, otherwise it is a reference to foo.
template <bool b, class Foo>
constexpr decltype(auto) bar(Foo && foo) {
if constexpr (b) {
return std::decay_t<Foo>{foo};
} else {
return (foo);
}
}
template <bool b>
auto baz(Foo& foo) {
decltype(auto) fu = bar<b>(foo);
...
}
If not, is it even possible? And how would it be done?