I think there is a misconception about bayonet charges and melee. The bayonet charge was common. what was uncommon was that it hit home. Usually either the defender withdrew or routed or the attacker withdrew or routed to withering musket fire.
Melee was much more commen in town/village/building where the defender was less likely to give ground to a bayenet charge but also had less muskets concentrated on the attacker thus melee was more common in this instance.
I would like to add that Napoleon's combined arms doctrine was to enable the Line infantry to charge with bayonet. Artillery to soften up the opponent for the infantry to charge with bayonet, the cavalry to protect the infantry and to give confidence to the attack columns.
One of Ney's statements seem to characterize the French army of the Napoleonic era "In offensive warfare the French soldier has inexaustible resources;his active genius, and his bravery in storming, double his energy; and a french commander ought never to hesitate in marching against the enemy with the bayonet, if the ground is at all adapted to a charge in line with one or more battalions at a time. It is by attacking that the french soldier has become accustomed in warfare."
Prolonged fire fights were to be avoided if the troops are to attack; It would be better, therefore , after the first two ranks have fired, to charge boldly with the bayonet and by act of elan force the enemy to retreat.
sorces Armies of the Danube 1809 by Scott Bowden and The Glory Years 1805-1807 by Scott Bowden.