Replaced the hand-coded casting type with the decltype keyword