It is the first time in nearly 40 years that a reigning monarch has visited a Royal Navy warship at sea.