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.
Loading...
Searching...
No Matches
jh::concepts::is_contiguous_reallocable Concept Reference

Concept that constrains types usable in contiguous, reallocating containers. More...

#include <jh/conceptual/container_traits.h>

Concept definition

template<typename T>
std::is_object_v<T> &&
std::assignable_from<T &, T> &&
(std::is_move_constructible_v<T> || std::is_copy_constructible_v<T>)
Concept that constrains types usable in contiguous, reallocating containers.
Definition container_traits.h:335

Detailed Description

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.

Semantic requirements

A type T satisfies is_contiguous_reallocable if and only if:

  1. Object type: T is an object type (std::is_object_v<T>).
  2. 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.

  3. Reallocation support: 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.
Intended use

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.

Template Parameters
TElement type to be checked.