Subject: [Boost-bugs] [Boost C++ Libraries] #9436: Add predefined concept for contextual conversion to bool
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-11-26 15:31:25
#9436: Add predefined concept for contextual conversion to bool
------------------------------+-----------------------------
Reporter: akrzemi1@⦠| Owner: steven_watanabe
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: type_erasure
Version: Boost 1.54.0 | Severity: Not Applicable
Keywords: operator bool() |
------------------------------+-----------------------------
One concept that is often useful in many types is a contextual conversion
to bool. The following expressions should be valid with the concept:
{{{
if (o) {}
if (!o) {}
return bool(o);
}}}
Add a predefined concept that catches these requirement. A possible
implementation:
{{{
namespace boost { namespace type_erasure {
template<class T>
struct testable
{
static bool apply(const T& arg)
{ return bool(arg); }
};
template<class T, class Base>
struct concept_interface<testable<T>, Base, T> : Base
{
explicit operator bool () const
{ return call(testable<T>(), *this); }
};
}}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9436> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:14 UTC