...one of the most highly
regarded and expertly designed C++ library projects in the
world.

— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards

template< typename T1 , typename T2 > struct equal_to { typedefunspecifiedtype; };

Returns `true_`

if `T1::value == T2::value`

and `false_`

otherwise [1].

#include "boost/mpl/equal_to.hpp"

Parameter | Requirement | Description |
---|---|---|

`T1, T2` | A model of Integral Constant |

Expression | Expression type | Precondition | Semantics | Postcondition |
---|---|---|---|---|

`typedef equal_to<t1,t2>::type c;` | A model of `bool` Integral Constant | Equivalent to `typedef bool_<(t1::value == t2::value)> c;` |

Amortized constant time.

typedef list_c<int,1,2,3,5,7,12,19,31> fibonacci; typedef find_if< fibonacci, equal_to<_1,int_<12> > >::type iter; BOOST_STATIC_ASSERT(equal_to< distance< begin<fibonacci>::type, iter >::type, int_<5> >::type::value));

[1] The `equal_to`

metafunction can be (and is expected to be) specialized by user to work on user-defined types that do not satisfy the Integral Constant requirements. The requirements listed here are the ones imposed by the default implementation.

Metafunctions, `not_equal_to`

, `less`

, `less_equal`

, `greater`

, `greater_equal`

Table of Contents

Last edited March 10, 2003 6:26 am