Boost logo

Boost :

Subject: Re: [boost] Library proposal: binconst, constant of the binary form.
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2009-01-16 14:28:36

On Thu, Jan 15, 2009 at 4:17 PM, TaeKyeong Wang <bugiii_at_[hidden]> wrote:

> I know BOOST_BINARY. It is a excellent tool, but error message of
> following expression is confused.

During review there were actually two proposed solutions to representing
binary literals -- one was template-based, similar in some ways to your own,
and the other was macro based. The macro version is what was accepted for
various reasons. While you get an odd error message for BOOST_BINARY(
01234), a mistake which is very clear from looking at the code rather than
the error message anyway, you get much better error messages from the macro
version for more subtle mistakes such as trying to produce a literal that is
too large for an integer to hold (it will give you the same error message
your compiler produces for creating an octal literal that is too large). As
well, the type of the literal yielded by the macro version follows the exact
same rules as those of octal and hex literals in C++, whereas the template
version will not. Templates are also notorious for their costly
instantiation times and it is generally not worth it to use them for
something like this where a pure macro version is available and also more
accurately represents the desired behavior.
I'm just defending the macro version here, but there are obviously benefits
and drawbacks to each approach. If you want to see why the macro version was
preferred over the template version, you can always read the reviews. It was
by no means a unanimous decision.

-Matt Calabrese

Boost list run by bdawes at, gregod at, cpdaniel at, john at