• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Macros/Asserts//BOOST_MPL_ASSERT
2
3BOOST_MPL_ASSERT
4================
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    #define BOOST_MPL_ASSERT( pred ) \\
12        |unspecified-token-seq| \\
13    /\*\*/
14
15
16Description
17-----------
18
19Generates a compilation error when the predicate ``pred`` holds false.
20
21
22Header
23------
24
25.. parsed-literal::
26
27    #include <boost/mpl/assert.hpp>
28
29
30Parameters
31----------
32
33+---------------+-----------------------------------+-------------------------------+
34| Parameter     | Requirement                       | Description                   |
35+===============+===================================+===============================+
36| ``pred``      | Boolean nullary |Metafunction|    | A predicate to be asserted.   |
37+---------------+-----------------------------------+-------------------------------+
38
39
40Expression semantics
41--------------------
42
43For any boolean nullary |Metafunction| ``pred``:
44
45
46.. parsed-literal::
47
48    BOOST_MPL_ASSERT(( pred ));
49
50:Return type:
51    None.
52
53:Semantics:
54    Generates a compilation error if ``pred::type::value != true``, otherwise
55    has no effect. Note that double parentheses are required even if no commas
56    appear in the condition.
57
58    When possible within the compiler's diagnostic capabilities,
59    the error message will include the predicate's full type name, and have a
60    general form of:
61
62    .. parsed-literal::
63
64       |...| \*\*\*\*\*\*\*\*\*\*\*\* pred::\*\*\*\*\*\*\*\*\*\*\*\* |...|
65
66
67Example
68-------
69
70::
71
72    template< typename T, typename U > struct my
73    {
74        // ...
75        BOOST_MPL_ASSERT(( is_same< T,U > ));
76    };
77
78    my<void*,char*> test;
79
80    // In instantiation of `my<void, char*>':
81    //   instantiated from here
82    // conversion from `
83    //   mpl_::failed************boost::is_same<void, char*>::************' to
84    //   non-scalar type `mpl_::assert<false>' requested
85
86
87See also
88--------
89
90|Asserts|, |BOOST_MPL_ASSERT_NOT|, |BOOST_MPL_ASSERT_MSG|, |BOOST_MPL_ASSERT_RELATION|
91
92
93.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
94   Distributed under the Boost Software License, Version 1.0. (See accompanying
95   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
96