Maybe typeof(return) is what you're looking for? * auto foo() { return map!("a * a")([1, 2, 3, 4]); static assert(is(Unqual!(ForeachType!(typeof(return))) == int)); } * Not tested, I don't know if it works like this at all.