( n < b ? "" : base( n / b, b ) )
If n is less than b then this part is just "" (empty string)
otherwise it recursively moves on to n / b (remaining hexadecimal digits to the left).
+ "0123456789ABCDEF"[ n % b ];
n%b is the index of the last digit in base b (here, 16). Then use this index of the c-string "0123456789ABCDEF" to get this last hexadecimal digit.
out << setfill( '0' );
Fills any space in front with character '0', in case you want to write a 1-digit number into a 2-digit field, and need the 0 characters in front.
out <<
I've used out so that you could easily direct this stream to where you want to (e.g. file). At the moment it is a reference to standard out (cout).
<< setw( 2 )
Write the next item (only) to a field of minimum width 2.
I think the rest of that line is standard c++ output.