inflation is relative with the relation between the amount of goods and amount of money. if there is too much money, inflation happen. keeping stocks certainly keeps you far from inflation. but the more important issue is growth. if a company grows because of its competitive advantage, its stock price increases a lot. this increase is many times higher than inflation.
for companies which do not grow or shrink, keeping their equities COULD normally protect you from inflation. but this is not sure. for some reasons, some companies can not increase product price and so, we can not have this protection. some companies are not free to work in market oriented economies.
some companies shrink because they loose their market share to other companies or because their industry demand goes down as the case with oil industry analyzed above. keeping the stocks of these companies is suicide.
so, keeping stocks of companies is not simple. if you choose good companies, you get much more than protection against inflation.
keeping stocks is doing business. the award is more than protection against inflation. the consequence is a half of you asset is gone
so, the point is the companies grow or not. end of the story.