49 #ifndef LIB_REPLACEABLE_ITEM_H 50 #define LIB_REPLACEABLE_ITEM_H 57 #include <type_traits> 78 template<
typename X,
typename COND =
void>
82 std::byte content_[
sizeof(X)];
97 emplace (forward<Z> (otherValue));
102 operator= (Z&& otherValue)
104 if (not isSameObject(*
this, otherValue))
105 reAssign (forward<Z> (otherValue));
116 operator X&() {
return access(); }
117 operator X
const&()
const {
return unConst(
this)->access(); }
119 X&
get() {
return access(); }
120 X
const&
get()
const {
return unConst(
this)->access(); }
127 return * std::launder (reinterpret_cast<X*> (&content_));
138 emplace (Z&& otherValue)
140 new(&content_) X{forward<Z> (otherValue)};
148 reAssign (Z&& otherValue)
151 emplace (forward<Z> (otherValue));
159 : std::__and_<std::is_copy_assignable<X>, std::__not_<std::is_reference<X>>>
178 ReplaceableItem& operator= (X && val) { val_=forward<X>(val);
return *
this; }
181 operator X&() {
return val_; }
182 operator X
const&()
const {
return val_; }
184 X&
get() {
return val_; }
185 X
const&
get()
const {
return val_; }
193 static_assert( not
sizeof(X),
"ReplaceableItem for references is pointless");
203 return li.get() == ri.get();
209 return li.get() != ri.get();
212 template<
typename X,
typename Z>
216 return item.get() == something;
218 template<
typename X,
typename Z>
222 return item.get() != something;
225 template<
typename Z,
typename X>
229 return item.get() == something;
231 template<
typename Z,
typename X>
235 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, based directly on the referee's memory identities. ...