Add generic var and std for iterables, fix #6544
Fix type stability
Merge pull request #6545 from IainNZ/patch-7

Add generic var and std for iterables, fix #6544