Skip to content
Snippets Groups Projects
Commit a56767de authored by Carsten Gräser's avatar Carsten Gräser
Browse files

[bugfix] Make identity properly forwrad l-values

parent 2892e007
No related branches found
No related tags found
No related merge requests found
...@@ -300,22 +300,22 @@ namespace Imp { ...@@ -300,22 +300,22 @@ namespace Imp {
template<class IfFunc, class ElseFunc> template<class IfFunc, class ElseFunc>
constexpr void ifElse(std::true_type, IfFunc&& ifFunc, ElseFunc&& elseFunc) constexpr void ifElse(std::true_type, IfFunc&& ifFunc, ElseFunc&& elseFunc)
{ {
ifFunc([](auto&& x) { return std::forward<decltype(x)>(x);}); ifFunc([](auto&& x) -> decltype(auto) { return std::forward<decltype(x)>(x);});
} }
template<class IfFunc, class ElseFunc> template<class IfFunc, class ElseFunc>
constexpr void ifElse(std::false_type, IfFunc&& ifFunc, ElseFunc&& elseFunc) constexpr void ifElse(std::false_type, IfFunc&& ifFunc, ElseFunc&& elseFunc)
{ {
elseFunc([](auto&& x) { return std::forward<decltype(x)>(x);}); elseFunc([](auto&& x) -> decltype(auto) { return std::forward<decltype(x)>(x);});
} }
template<class IfFunc, class ElseFunc> template<class IfFunc, class ElseFunc>
constexpr void ifElse(const bool& condition, IfFunc&& ifFunc, ElseFunc&& elseFunc) constexpr void ifElse(const bool& condition, IfFunc&& ifFunc, ElseFunc&& elseFunc)
{ {
if (condition) if (condition)
ifFunc([](auto&& x) { return std::forward<decltype(x)>(x);}); ifFunc([](auto&& x) -> decltype(auto) { return std::forward<decltype(x)>(x);});
else else
elseFunc([](auto&& x) { return std::forward<decltype(x)>(x);}); elseFunc([](auto&& x) -> decltype(auto) { return std::forward<decltype(x)>(x);});
} }
} // namespace Imp } // namespace Imp
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment