Ultra 0.9.4
Loading...
Searching...
No Matches
individual::modify_proxy Class Reference

Public Member Functions

const individual & self () const noexcept
auto & genome () noexcept
value_type & operator[] (std::size_t i) noexcept
std::size_t size () const noexcept

Friends

class individual

Detailed Description

Proxy granting controlled write access to an individual.

modify_proxy is a capability object created exclusively by individual::modify(). It provides temporary, scoped permission to mutate the internal genome of an individual.

The proxy must not escape the scope of the call to modify(). All class invariants of individual are guaranteed to hold again when individual::modify() returns.

Users must not assume any invariant holds while operating on the proxy, except those explicitly documented.

Member Function Documentation

◆ operator[]()

value_type & individual::modify_proxy::operator[] ( std::size_t i)
inlinenodiscardnoexcept

Mutable access to a genome element.

Parameters
[in]iindex of the gene to access
Returns
a mutable reference to the requested gene
Precondition
i < size()

Provides write access to the gene at position i. This function is only callable within the scope of individual::modify().

◆ self()

const individual & individual::modify_proxy::self ( ) const
inlinenodiscardnoexcept

Access the owning individual in read-only mode.

Returns
a const reference to the owning individual

This allows inspection of the individual while mutation is in progress, without granting additional write access.

◆ size()

std::size_t individual::modify_proxy::size ( ) const
inlinenodiscardnoexcept

Number of genes in the genome.

Returns
the size of the genome

The documentation for this class was generated from the following file: