Added bool_testable by Sam Partington

[SVN r18413]
This commit is contained in:
Daniel Frey
2003-05-15 22:40:33 +00:00
parent 1be04eeec5
commit 88f4e47550
3 changed files with 179 additions and 1 deletions
+13
View File
@@ -9,6 +9,7 @@
// See http://www.boost.org/libs/utility/operators.htm for documentation.
// Revision History
// 04 May 05 Added operator class bool_testable. (Sam Partington)
// 21 Oct 02 Modified implementation of operators to allow compilers with a
// correct named return value optimization (NRVO) to produce optimal
// code. (Daniel Frey)
@@ -308,6 +309,18 @@ struct indexable : B
}
};
// bool_testable -----------------------------------------------------------//
// (contributed by Sam Partington, David Abrahams and Daniel Frey) ---------//
template <class T, class B = ::boost::detail::empty_base>
struct bool_testable : B
{
friend bool operator!(const T& t) { return !static_cast<bool>(t); }
private:
typedef signed char private_number_type;
operator private_number_type() const;
};
// More operator classes (contributed by Daryle Walker) --------------------//
// (NRVO-friendly implementation contributed by Daniel Frey) ---------------//