Can pilots smoke in the cockpit of an airliner? An answer on travel.se suggests that some pilots are smoking on long-distance passenger flights. 

Can passenger airliner pilots smoke if both the captain and first officer agree it’s ok? If I recall, smoking is only prohibited on flights that require cabin crew as a crew health issue (sidestream smoke) and not as flight safety issue. Given that cabin crew are not on the flight deck, is there anything that prevents a pilot on a larger airline from lighting up?

For the purposes of the question, let’s consider flights originating in  USA, EU, UAE, and China as the four biggest country/areas.
All of the most significant countries prohibit smoking on airline flights, either through national, industry, or airline regulations. This applies to crew through different regulations, but as strictly as to the passengers.

Pilots can and sometimes do smoke in the cockpits of business jets. These can be as large as airliners (see BBJ), but usually aren't.