Opened 10 years ago

Last modified 10 years ago

#6921 new Bugs

documentation for BOOST_MPL_ASSERT_RELATION inconsistent with implementation

Reported by: Robert Ramey Owned by: Aleksey Gurtovoy
Milestone: To Be Determined Component: mpl
Version: Boost 1.49.0 Severity: Problem
Keywords: Cc:

Description

Documenation for MPL states that the proper syntax BOOST_MPL_ASSERT_RELATION is:

BOOST_MPL_ASSERT_RELATION( x, op, y );

where x and y are integral constants.

Given this, the following assert should trap since 8 is not an integral constant

BOOST_MPL_ASSERT_RELATION(8, ==, 8); // no assertion 

But in fact it does not.

On the other hand, the following should not trap

BOOST_MPL_ASSERT_RELATION(
    (boost::mpl::integral_c<int, 8>), 
    ==, 
    (boost::mpl::integral_c<int, 8>)
);

But in fact it does.

So it seems that the documentation doesn't agree with the implementation.

Robert Ramey

Change History (3)

comment:1 by viboes, 10 years ago

I don't think the documentation is referring to the class integral_constant, but to the built-in integral constants/literals.

comment:2 by Robert Ramey, 10 years ago

http://www.boost.org/doc/libs/1_49_0/libs/mpl/doc/refmanual/integral-constant.html

defines "integral constant" as a concept.

http://www.boost.org/doc/libs/1_49_0/libs/mpl/doc/refmanual/assert-relation.html

shows

Synopsis

#define BOOST_MPL_ASSERT_RELATION( x, relation, y ) \

unspecified token sequence \

with parameter x and y required to be "integral constant"

The example shows

BOOST_MPL_ASSERT_RELATION( sizeof(T), <, sizeof(U) );

which supports your reading. At the very least the document has to be considered confusing and in need of improvement.

Robert Ramey

comment:3 by anonymous, 10 years ago

Actually, I would prefer that the macro be re-implemented to support either usage

Note: See TracTickets for help on using tickets.