# concepts

***

**1. Concept for Type Checking:**

```cpp
template<typename T>
concept Number = requires(T x) {
    x + x;
};
```

Ensures `T` has a `+` operator.

**2. Concept for Predicate:**

```cpp
template<typename T>
concept Predicate = requires(T x) {
    { x(42) } -> bool;
};
```

Verifies `T` is a callable that returns a boolean.

**3. Concept for Iterator:**

```cpp
template<typename T>
concept Iterator = requires(T x) {
    x++;
    *x;
};
```

Checks for the presence of increment and dereference operators.

**4. Concept for Range:**

```cpp
template<typename T>
concept Range = requires(T x) {
    Iterator<decltype(x.begin())>;
    Iterator<decltype(x.end())>;
};
```

Ensures `T` has `begin()` and `end()` returning iterators.

**5. Concept for Copyable:**

```cpp
template<typename T>
concept Copyable = requires(T x) {
    T copy = x;
};
```

Verifies `T` can be copied using the assignment operator.

**6. Concept for Moveable:**

```cpp
template<typename T>
concept Moveable = requires(T x) {
    T copy = std::move(x);
};
```

Checks `T` can be moved using `std::move`.

**7. Concept for Default Constructible:**

```cpp
template<typename T>
concept DefaultConstructible = requires {
    T();
};
```

Ensures `T` has a default constructor.

**8. Concept for Output Iterator:**

```cpp
template<typename T>
concept OutputIterator = requires(T x) {
    *x = 42;
};
```

Verifies `*x` can be assigned a value.

**9. Concept for Input Iterator:**

```cpp
template<typename T>
concept InputIterator = requires(T x) {
    *x++;
};
```

Checks `*x` can be incremented.

**10. Concept for Forward Iterator:**

```cpp
template<typename T>
concept ForwardIterator = requires(T x, T y) {
    x++;
    x == y;
};
```

Ensures `++` and `==` operators work correctly.

**11. Concept for Bidirectional Iterator:**

```cpp
template<typename T>
concept BidirectionalIterator = requires(T x, T y) {
    ForwardIterator<T>;
    x--;
    x == y;
};
```

Verifies the `--` operator exists and works as expected.

**12. Concept for Random Access Iterator:**

```cpp
template<typename T>
concept RandomAccessIterator = requires(T x, T y) {
    BidirectionalIterator<T>;
    x + 42;
    x - 42;
};
```

Ensures `+` and `-` operators support random access.

**13. Concept for Less Than Comparable:**

```cpp
template<typename T>
concept LessThanComparable = requires(T x, T y) {
    x < y;
};
```

Verifies `T` can be compared using `<`.

**14. Concept for Equality Comparable:**

```cpp
template<typename T>
concept EqualityComparable = requires(T x, T y) {
    x == y;
};
```

Checks `T` can be compared for equality using `==`.

**15. Concept for Pointer:**

```cpp
template<typename T>
concept Pointer = requires(T x) {
    *x;
};
```

Ensures `T` is a pointer type that can be dereferenced.

**16. Concept for Reference:**

```cpp
template<typename T>
concept Reference = requires(T x) {
    *x;
};
```

Verifies `T` is a reference type that can be dereferenced.

**17. Concept for Array:**

```cpp
template<typename T>
concept Array = requires(T x) {
    T[42];
};
```

Checks `T` is an array type that supports indexing.

**18. Concept for Function Pointer:**

```cpp
template<typename T>
concept FunctionPointer = requires(T x) {
    x(42);
};
```

Ensures `T` is a function pointer that can be called.

**19. Concept for Callable Object:**

```cpp
template<typename T>
concept CallableObject = requires(T x) {
    x();
};
```

Verifies `T` is a callable object that can be invoked.

**20. Concept for Regular Expression:**

```cpp
template<typename T>
concept Regex = requires(T x) {
    std::regex_match("text", x);
};
```

Checks `T` is a regular expression that can be matched against text.

**21. Concept for Tuple:**

```cpp
template<typename T>
concept Tuple = requires(T x) {
    std::get<0>(x);
};
```

Ensures `T` is a tuple that supports accessing elements by index.

**22. Concept for Void Function:**

```cpp
template<typename T>
concept VoidFunction = requires(T x) {
    x();
};
```

Verifies `T` is a function that returns void.

**23. Concept for Copy Constructible:**

```cpp
template<typename T>
concept CopyConstructible = requires(T x, T y) {
    T copy(x);
};
```

Ensures `T` can be copy constructed from another object of the same type.

**24. Concept for Move Constructible:**

```cpp
template<typename T>
concept MoveConstructible = requires(T x, T y) {
    T copy = std::move(x);
};
```

Verifies `T` can be move constructed from another object of the same type.

**25. Concept for Assignable:**

```cpp
template<typename T>
concept Assignable = requires(T x, T y) {
    x = y;
};
```

Checks `T` supports the assignment operator.

**26. Concept for Swappable:**

```cpp
template<typename T>
concept Swappable = requires(T x, T y) {
    std::swap(x, y);
};
```

Ensures `T` can be swapped using the `std::swap` function.

**27. Concept for Destructible:**

```cpp
template<typename T>
concept Destructible = requires(T x) {
    ~x;
};
```

Verifies `T` has a destructor.

**28. Concept for Integral:**

```cpp
template<typename T>
concept Integral = requires(T x) {
    x + 1;
};
```

Checks `T` is an integral type that supports arithmetic operations.

**29. Concept for Floating Point:**

```cpp
template<typename T>
concept FloatingPoint = requires(T x) {
    x + 1.0;
};
```

Ensures `T` is a floating-point type that supports arithmetic operations.

**30. Concept for Boolean:**

```cpp
template<typename T>
concept Boolean = requires(T x) {
    x && true;
};
```

Verifies `T` is a boolean type that supports logical operations.

**31. Concept for String:**

```cpp
template<typename T>
concept String = requires(T x) {
    x.size();
};
```

Checks `T` is a string type that supports accessing the length.

**32. Concept for Vector:**

```cpp
template<typename T>
concept Vector = requires(T x) {
    x.size();
    x.push_back(42);
};
```

Ensures `T` is a vector type that supports accessing the length and pushing elements.

**33. Concept for List:**

```cpp
template<typename T>
concept List = requires(T x) {
    x.size();
    x.push_back(42);
    x.front();
};
```

Verifies `T` is a list type that supports accessing the length, pushing elements, and getting the first element.

**34. Concept for Set:**

```cpp
template<typename T>
concept Set = requires(T x) {
    x.size();
    x.insert(42);
};
```

Checks `T` is a set type that supports accessing the length and inserting elements.

**35. Concept for Map:**

```cpp
template<typename T>
concept Map = requires(T x) {
    x.size();
    x[42] = "value";
};
```

Ensures `T` is a map type that supports accessing the length and inserting/accessing elements by key.

**36. Concept for Optional:**

```cpp
template<typename T>
concept Optional = requires(T x) {
    x.has_value();
    x.value();
};
```

Verifies `T` is an optional type that supports checking for a value and accessing the value if present.

**37. Concept for Union:**

```cpp
template<typename T>
concept Union = requires(T x) {
    x.contains<int>();
    x.get<int>();
};
```

Checks `T` is a union type that supports checking for and accessing elements of a specific type.

**38. Concept for Variant:**

```cpp
template<typename T>
concept Variant = requires(T x) {
    x.index();
    std::get<int>(x);
};
```

Ensures `T` is a variant type that supports accessing the index and getting elements of a specific type.

**39. Concept for Iterator Pair:**

```cpp
template<typename T>
concept IteratorPair = requires(T x) {
    x.first;
    x.second;
};
```

Verifies `T` is a pair of iterators that can be accessed by `first` and `second`.

**40. Concept for Pair:**

```cpp
template<typename T>
concept Pair = requires(T x) {
    x.first;
    x.second;
};
```

Checks `T` is a pair that can be accessed by `first` and `second`.

**41. Concept for Triple:**

```cpp
template<typename T>
concept Triple = requires(T x) {
    x.first;
    x.second;
    x.third;
};
```

Ensures `T` is a triple that can be accessed by `first`, `second`, and `third`.

**42. Concept for Quadruple:**

```cpp
template<typename T>
concept Quadruple = requires(T x) {
    x.first;
    x.second;
    x.third;
    x.fourth;
};
```

Verifies `T` is a quadruple that can be accessed by `first`, `second`, `third`, and `fourth`.

**43. Concept for Reference Wrapper:**

```cpp
template<typename T>
concept ReferenceWrapper = requires(T x) {
    *x;
};
```

Checks `T` is a reference wrapper that can be dereferenced.

**44. Concept for Smart Pointer:**

```cpp
template<typename T>
concept SmartPointer = requires(T x) {
    *x;
};
```

Ensures `T` is a smart pointer that can be dereferenced.

**45. Concept for Container:**

```cpp
template<typename T>
concept Container = requires(T x) {
    x.begin();
    x.end();
};
```

Verifies `T` is a container type that supports accessing iterators to its elements.

**46. Concept for Associative Container:**

```cpp
template<typename T>
concept AssociativeContainer = requires(T x) {
    Container<T>;
    x.find(42);
};
```

Checks `T` is an associative container type that supports finding elements by key.

**47. Concept for Fixed-Size Buffer:**

```cpp
template<typename T>
concept FixedSizeBuffer = requires(T x) {
    x.size();
    x[42];
};
```

Ensures `T` is a fixed-size buffer type that supports accessing elements by index.

**48. Concept for Resizable Buffer:**

```cpp
template<typename T>
concept ResizableBuffer = requires(T x) {
    x.size();
    x.resize(42);
};
```

Verifies `T` is a resizable buffer type that supports accessing the length and resizing.

**49. Concept for File:**

```cpp
template<typename T>
concept File = requires(T x) {
    x.is_open();
    x.write("text");
};
```

Checks `T` is a file type that supports checking for being open and writing data.

**50. Concept for Thread:**

```cpp
template<typename T>
concept Thread = requires(T x) {
    x.start();
    x.join();
};
```

Ensures `T` is a thread type that supports starting and joining.
