Use decltype in algorithm