58 #ifndef LIB_REPLACEABLE_ITEM_H 59 #define LIB_REPLACEABLE_ITEM_H 66 #include <type_traits> 87 template<
typename X,
typename COND =
void>
91 std::byte content_[
sizeof(X)];
106 emplace (forward<Z> (otherValue));
111 operator= (Z&& otherValue)
113 if (not isSameObject(*
this, otherValue))
114 reAssign (forward<Z> (otherValue));
125 operator X&() {
return access(); }
126 operator X
const&()
const {
return unConst(
this)->access(); }
128 X&
get() {
return access(); }
129 X
const&
get()
const {
return unConst(
this)->access(); }
136 return * std::launder (reinterpret_cast<X*> (&content_));
147 emplace (Z&& otherValue)
149 new(&content_) X{forward<Z> (otherValue)};
157 reAssign (Z&& otherValue)
160 emplace (forward<Z> (otherValue));
168 : std::__and_<std::is_copy_assignable<X>, std::__not_<std::is_reference<X>>>
187 ReplaceableItem& operator= (X && val) { val_=forward<X>(val);
return *
this; }
190 operator X&() {
return val_; }
191 operator X
const&()
const {
return val_; }
193 X&
get() {
return val_; }
194 X
const&
get()
const {
return val_; }
202 static_assert( not
sizeof(X),
"ReplaceableItem for references is pointless");
212 return li.get() == ri.get();
218 return li.get() != ri.get();
221 template<
typename X,
typename Z>
225 return item.get() == something;
227 template<
typename X,
typename Z>
231 return item.get() != something;
234 template<
typename Z,
typename X>
238 return item.get() == something;
240 template<
typename Z,
typename X>
244 return item.get() != something;
bool operator==(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
Supporting equality comparisons...
Singleton holder for NIL or default value objects.
Singleton-style holder for NIL or default values.
Implementation namespace for support and library code.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Lumiera error handling (C++ interface).
Adapter container to take snapshots from non-assignable values.
bool isSameObject(A const &a, B const &b)
compare plain object identity, bypassing any custom comparison operators.