Workaround for the stupidity of gcc's max_element function