The trivial case of size=0 should not occur. Does it suffice to check with assertion that the container is non-empty?