Sequoia
|
Helper class to assist with copy assignment for allocator-aware types. More...
#include <AssignmentUtilities.hpp>
Static Public Member Functions | |
template<class T , std::invocable< T >... AllocGetters> | |
static constexpr void | assign (T &to, const T &from, AllocGetters... allocGetters) |
Helper class to assist with copy assignment for allocator-aware types.
Consider a type, T
, which is allocator-aware and for which copy assignment cannot be defaulted. Suppose that T
wraps containers Cs...
. To utilize the this helper, do the following:
T
.T
with a reset
method, the arguments of which are the allocators associated with Cs...
. Internally, reset
should construct instances Cs...
using the allocators and copy assign these to the wrapped containers. It is important that copy assignment is used since allocator propagation may differ between copying and moving.T
, together with a sequence of function objects which return the requisite allocators.This pattern has an extra layer of generality, an example of which may be seen in sequoia::maths::connectivity. Depending on how its template arguments are chosen, sequoia::maths::connectivity may wrap either one or two allocator-aware types. To deal with these situations homogeneously, assignment_helper::assign ignores any of the supplied function objects if they return void.
|
inlinestaticconstexpr |
Can be used to implement non-defaultable copy assignment for allocator-aware classes