|
Boost : |
Subject: Re: [boost] numeric_cast
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2011-06-23 17:43:02
[Fernando Cacciola]
> It looks fine to me (except maybe for the #pragma once... is that
> properly supported on all supported compilers?)
[Brandon Kohn]
> Ah, right. We use that at my work (all MSVC). So I'm acclimated. I'll
> remove those.
Actually, the best thing to do is this:
#ifndef MYPROJECT_MYDIRECTORY_FOOBAR_HPP
#define MYPROJECT_MYDIRECTORY_FOOBAR_HPP
#ifdef _MSC_VER
#pragma once
#endif // _MSC_VER
meow;
#endif // MYPROJECT_MYDIRECTORY_FOOBAR_HPP
This way, all compilers get the portable idempotency guard. Because it's on the outside, GCC (and possibly other compilers) will magically recognize it and avoid opening the header file twice. And the #pragma once for MSVC also instructs it to avoid opening the header file twice, which can improve build perf and can't hurt.
Stephan T. Lavavej
Visual C++ Libraries Developer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk