Subject: Re: [boost] [static_if] Is there interest in a `static if` emulation library?
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2014-09-01 01:27:45
On Sun, Aug 31, 2014 at 10:09 PM, Robert Ramey <ramey_at_[hidden]> wrote:
> pfultz2 wrote
> >> since the condition is known at compile time, can't the optimizer be
> >> counted on to
> >> compile only the corresponding code? Why doesn't this give the same
> >> effect as
> >> the proposal?
> > Both branches still have to compile even if the compiler determines it is
> > dead code.
> > Paul
> So what, the final executables would be equivalent if not identical.
If both branches are able to compile, then yes, probably. The problem is
that when you use this kind of branching, it's often the case that when the
condition is false, the true branch would have a compilation failure (or
vice versa). Regardless of which branch is taken, even when the condition
is a compile-time constant, both branches need to be compiled and any
templates involved need to be instantiated, so using a regular if either
could fail compilation or greatly increase compile-times, neither of which
-- -Matt Calabrese
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk