Use lexical_cast to get integer from string re #8397

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>