FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
ns_concept::Boolean Concept Reference

Concept for types that can be contextually converted to bool. More...

#include <concept.hpp>

Concept definition

template<typename T>
concept ns_concept::Boolean = std::convertible_to<std::remove_cvref_t<T>, bool>
&& requires(T t)
{
{ !t } -> std::convertible_to<bool>;
}
Concept for types that can be contextually converted to bool.
Definition concept.hpp:103

Detailed Description

Concept for types that can be contextually converted to bool.

Template Parameters
TThe type to check

This concept matches the standard library's boolean-testable requirements. Types satisfying this concept can be used in boolean contexts (if, while, etc.) and support logical negation.

Accepts: bool, int, pointers, std::optional, std::unique_ptr, etc.

Example:

template<Boolean T>
void do_if_true(T condition) { if (condition) { } }

Definition at line 103 of file concept.hpp.