Boost logo

Boost Users :

Subject: Re: [Boost-users] Template metaprogramming technique for operator overloading
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-12-15 08:04:43

2009/12/15 Edward Diener <eldiener_at_[hidden]>

> I could not find this in type_traits, or any other Boost TMP library, but I
> am wondering if there is any TMP technique which can determine if a
> user-defined type supports a particular operator overload for that type ?

Type Traits Extensions might help. It's not officially part of Boost, but
it's in the review queue.

:Author: Frédéric Bron

:Review Manager: Needed


The purpose of the addition is to add type traits to detect if types T and U
are comparable in the sens of <, <=, >, >=, == or != operators, i.e. if
t<u has a sens when t is of type T and u of type U (same for <=, >, >=, ==,

The following traits are added:


The names are based on the corresponding names of the standard
template library (<functional> header, section 20.3.3 of the

The code has the following properties:
* returns true if t<u is meaningful and returns a value convertible to bool
* returns false if t<u is meaningless.
* fails with compile time error if t<u is meaningful and returns void
(a possibility to avoid compile time error would be to return true
with an operator, trick but this has little sens as returning false
would be better)

Roman Perepelitsa.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at