58 #ifndef LIB_REPLACEABLE_ITEM_H 59 #define LIB_REPLACEABLE_ITEM_H 66 #include <type_traits> 86 template<
typename X,
typename COND =
void>
89 char content_[
sizeof(X)];
104 emplace (forward<Z> (otherValue));
109 operator= (Z&& otherValue)
111 if (not isSameObject(*
this, otherValue))
112 reAssign (forward<Z> (otherValue));
123 operator X&() {
return access(); }
124 operator X
const&()
const {
return unConst(
this)->access(); }
126 X&
get() {
return access(); }
127 X
const&
get()
const {
return unConst(
this)->access(); }
134 return reinterpret_cast<X&
>(content_);
145 emplace (Z&& otherValue)
147 new(&content_) X{forward<Z> (otherValue)};
155 reAssign (Z&& otherValue)
158 emplace (forward<Z> (otherValue));
166 : std::__and_<std::is_copy_assignable<X>, std::__not_<std::is_reference<X>>>
185 ReplaceableItem& operator= (X && val) { val_=forward<X>(val);
return *
this; }
188 operator X&() {
return val_; }
189 operator X
const&()
const {
return val_; }
191 X&
get() {
return val_; }
192 X
const&
get()
const {
return val_; }
200 static_assert( not
sizeof(X),
"ReplaceableItem for references is pointless");
210 return li.get() == ri.get();
216 return li.get() != ri.get();
219 template<
typename X,
typename Z>
223 return item.get() == something;
225 template<
typename X,
typename Z>
229 return item.get() != something;
232 template<
typename Z,
typename X>
236 return item.get() == something;
238 template<
typename Z,
typename X>
242 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.