|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
Concept that constrains types usable in contiguous, reallocating containers. More...
#include <jh/conceptual/container_traits.h>
Concept that constrains types usable in contiguous, reallocating containers.
This concept models the requirements for a type T to be safely used as an element type in containers that: store elements contiguously (e.g. std::vector, std::deque), and may perform reallocation and element relocation during growth.
In addition, it guarantees that elements obtained from the container (via operator[] or iterator dereference yielding T&) can be assigned from values produced externally.
A type T satisfies is_contiguous_reallocable if and only if:
T is an object type (std::is_object_v<T>). External assignability:
std::assignable_from<T&, T> ensures that an assignment expression of the form std::declval<T&>() = std::declval<T>() is well-formed.
This implies that T provides at least one viable assignment interface capable of assigning into an existing object from a value of the same type. The concrete form of this interface is intentionally unconstrained and may correspond to a move assignment, copy assignment, or a by-value assignment operator (e.g. copy-and-swap).
As a result, any location exposing a mutable reference to a contained element (such as operator[] or iterator dereference yielding T&) is guaranteed to support assignment by the user.
T is either move-constructible or copy-constructible (std::is_move_constructible_v<T> || std::is_copy_constructible_v<T>), guaranteeing that elements can be relocated when the container reallocates. This concept is designed to express the minimal semantic contract required by vector-like containers that:
reallocate their storage, and expose mutable references to their elements.
It is suitable for constraining generic algorithms or container adapters that assume both reallocation safety and external assignment into container elements.
| T | Element type to be checked. |