La bise,
Yes, it's a complex issue

It's not codified or written. Normally, you do this only with friends. Not with strangers, otherwise they'd feel uncomfortable. Most of the time, you shake hands, whether it be with your colleagues, your boss or anyone with whom you have no acquaintance or developped relations.
Then even with friends, it's hard:
- Women do kiss each other ( Kissing is a bit different from ' la bise' I know). A woman and a man will kiss each other. Two males might do it if they know each other very well ( virility is much in danger for some

).
- how many ' bises' ? it depends from the region you come from

...and there's no established custom

Some say in Paris, you do 3 ' bises', in the South of France, it's normally 2 and in the North, 4 is a good average

... That's always a funny moment, when you think the pomp is over and suddenly the person in front of you is getting ready for one more round
It's not a matter of class or social rank. But I guess that ' la bise' in the upper classes is much more for ' private persons'....
It might be a friendly custom but for some, it looks like an intrusive way of saying ' hello'
Shaking hands is safer til you get to know the persons
