How can we know which operating system the code is running?

e.g.
How to know the operating system like Unix-Linux, Solaris, HP Unix, Windows, Mac etc?

How can we determine operating system in C++ code with boost?
I want to test with Boost v1.41 onwards.