Template:cpp/strong exception safety guarantee

If an exception is thrown for any reason, this function has no effect (strong exception safety guarantee).