Concepts#

Concepts and concept utilizing functions.

Info

To use declarations from this page, include the <essence/concepts.hpp> header.

template<typename T, typename ...Args>
concept anyof#

A concept useful for creating other concepts in which only one of the listed types must match.

Valid Expressions

  • T when T is any of the types listed in Args.

Example

template<typename T>
concept stringlike = anyof<T, std::string, std::string_view, const char*, char>;
template<typename T, typename ...Args>
bool matches(const T &value, const Args&... args)#

Apply the == operator between T for each arg in args. Each type must be of the same type as T, or of a type that passes std::equality_comparable_with.

Example

if (foo == 1 || foo == 2 || foo == 3 || foo == 4) ;

// The above may be collaped using the `matches` function like so:
if (matches(foo, 1, 2, 3, 4)) ;
template<typename T>
concept scannable#

A type that can be scanned with the io::scan() and io::prompt() functions.

Valid Expressions

  • T when T is a char (std::same_as<T, char>)

  • T when T is an integral type (std::integral<T>)

  • T when T is a floating point type (std::floating_point<T>)

  • T when T is convertible to std::string (std::convertible_to<T, std::string>)