• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Macros/Asserts//BOOST_MPL_ASSERT_RELATION
2
3BOOST_MPL_ASSERT_RELATION
4=========================
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    #define BOOST_MPL_ASSERT_RELATION( x, relation, y ) \\
12        |unspecified-token-seq| \\
13    /\*\*/
14
15
16
17Description
18-----------
19
20A specialized assertion macro for checking numerical conditions. Generates
21a compilation error when the condition ``( x relation y )``
22doesn't hold.
23
24
25Header
26------
27
28.. parsed-literal::
29
30    #include <boost/mpl/assert.hpp>
31
32
33Parameters
34----------
35
36+---------------+-----------------------------------+-----------------------------------------------+
37| Parameter     | Requirement                       | Description                                   |
38+===============+===================================+===============================================+
39| ``x``         | An integral constant              | Left operand of the checked relation.         |
40+---------------+-----------------------------------+-----------------------------------------------+
41| ``y``         | An integral constant              | Right operand of the checked relation.        |
42+---------------+-----------------------------------+-----------------------------------------------+
43| ``relation``  | A C++ operator token              | An operator token for the relation being      |
44|               |                                   | checked.                                      |
45+---------------+-----------------------------------+-----------------------------------------------+
46
47
48Expression semantics
49--------------------
50
51For any integral constants ``x``, ``y`` and a legal C++ operator token ``op``:
52
53
54.. parsed-literal::
55
56    BOOST_MPL_ASSERT_RELATION( x, op, y );
57
58:Return type:
59    None.
60
61:Semantics:
62    Generates a compilation error if ``( x op y ) != true``, otherwise
63    has no effect.
64
65    When possible within the compiler's diagnostic capabilities,
66    the error message will include a name of the relation being checked,
67    the actual values of both operands, and have a general form of:
68
69    .. parsed-literal::
70
71        |...| \*\*\*\*\*\*\*\*\*\*\*\*\ |...|\ assert_relation<op, x, y>::\*\*\*\*\*\*\*\*\*\*\*\*) |...|
72
73
74Example
75-------
76
77::
78
79    template< typename T, typename U > struct my
80    {
81        // ...
82        BOOST_MPL_ASSERT_RELATION( sizeof(T), <, sizeof(U) );
83    };
84
85    my<char[50],char[10]> test;
86
87    // In instantiation of `my<char[50], char[10]>':
88    //   instantiated from here
89    // conversion from `
90    //   mpl_::failed************mpl_::assert_relation<less, 50, 10>::************'
91    //   to non-scalar type `mpl_::assert<false>' requested
92
93
94See also
95--------
96
97|Asserts|, |BOOST_MPL_ASSERT|, |BOOST_MPL_ASSERT_NOT|, |BOOST_MPL_ASSERT_MSG|
98
99
100.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
101   Distributed under the Boost Software License, Version 1.0. (See accompanying
102   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
103