Boost logo

Boost :

Subject: Re: [boost] numeric_cast
From: Lars Viklund (zao_at_[hidden])
Date: 2011-06-27 17:03:00


On Mon, Jun 27, 2011 at 04:42:43PM -0400, Edward Diener wrote:
> On 6/27/2011 12:59 PM, Stephan T. Lavavej wrote:
>> [Mateusz Loskot]
>>> Is location of #pragma relevant? Meaning, having #pragma nested in
>>> #ifndef include guard vs. placing it in outer scope, makes difference or
>>> not?
>>
>> VC doesn't care where the #pragma once is, but as I recall, other
>> compilers care where the #ifndef is - they prefer it to be on the
>> outside of everything else, except comments.
>
> I doubt if any compiler cares where the #ifndef ( or #if !defined ) is.

I would reckon that compilers and preprocessor implementations may have
fast-paths that they go into if they detect something that looks like an
include guard very early in the file, where they can cheaply reject it
if already included with a minimum of work, if they guarantee
correctness.

After, all, it's a very common operation, it's most probably very
beneficial for cutting preprocessing costs.

> It is just C++ after all and the preprocessor should handle it according
> to the C++ standard.

As long as you have the proper semantics, optimizing such a case would
be quite allowed.

-- 
Lars Viklund | zao_at_[hidden]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk