RequiresExpressionExample Class | Qt 1.0
Description: A class demonstrating requires-expressions for ad-hoc constraints.
Keywords: class

# RequiresExpressionExample Class

A class demonstrating requires-expressions for ad-hoc constraints. More...

Header: | `#include <concepts.h>`

- List of all members, including inherited members

## Public Functions

int | getSize(const T &container)
void | iterate(T &container)

## Detailed Description

Requires-expressions use the nested `requires requires(...) { ... }` syntax to define constraints inline without defining a named concept.

## Member Function Documentation

### template <typename T> requires requires(T t) { t.size(); } int RequiresExpressionExample::getSize(const T &container)

Gets the size of container using a simple requires-expression.

Demonstrates a requires-expression that checks for a `size()` member function.

### template <typename T> requires requires(T t) { t.begin(); t.end(); } void RequiresExpressionExample::iterate(T &container)

Iterates over container using a requires-expression.

The requires-expression checks that the type has `begin()` and `end()` member functions, making it iterable.