boostorg / boostorg/type_erasure
add a concept for contextual conversion to bool
- Dominant language
- C++
- Stars
- 18
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
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) {}
template
bool test(O&& o) { return o; }
```
Add a predefined concept that catches these requirement. A possible implementation:
```
namespace boost { namespace type_erasure {
template
struct testable
{
static bool apply(const T& arg)
{ return bool(arg); }
};
template
struct concept_interface, Base, T> : Base
{
explicit operator bool () const
{ return call(testable(), *this); }
};
}}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the type_erasure concept_interface and call machinery referenced in the issue, then trace how predefined concepts are declared and exposed. Define the contextual bool concept so the listed if, negation, and bool-returning expressions are valid, and verify each expression with the project's existing tests or test conventions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100