ref: update formatting
This commit is contained in:
parent
7d0155d8ce
commit
024407225c
16 changed files with 433 additions and 377 deletions
|
|
@ -17,7 +17,7 @@ private:
|
|||
|
||||
void destroy() {
|
||||
if (initialized) {
|
||||
((T*) buffer)->~T();
|
||||
((T*)buffer)->~T();
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -51,23 +51,24 @@ public:
|
|||
}
|
||||
|
||||
T* operator->() {
|
||||
return (T*) buffer;
|
||||
return (T*)buffer;
|
||||
}
|
||||
|
||||
T& operator*() {
|
||||
return *((T*) buffer);
|
||||
return *((T*)buffer);
|
||||
}
|
||||
|
||||
const T* operator->() const {
|
||||
return (const T*) buffer;
|
||||
return (const T*)buffer;
|
||||
}
|
||||
|
||||
const T& operator*() const {
|
||||
return *((const T*) buffer);
|
||||
return *((const T*)buffer);
|
||||
}
|
||||
|
||||
optional& operator=(const optional& other) {
|
||||
if (this == &other) return *this;
|
||||
if (this == &other)
|
||||
return *this;
|
||||
destroy();
|
||||
if (other.initialized) {
|
||||
new (buffer) T(*other);
|
||||
|
|
@ -77,7 +78,8 @@ public:
|
|||
}
|
||||
|
||||
optional& operator=(optional&& other) noexcept {
|
||||
if (this == &other) return *this;
|
||||
if (this == &other)
|
||||
return *this;
|
||||
destroy();
|
||||
if (other.initialized) {
|
||||
new (buffer) T(move(*other));
|
||||
|
|
@ -92,11 +94,11 @@ public:
|
|||
}
|
||||
|
||||
T& value() {
|
||||
return *((T*) buffer);
|
||||
return *((T*)buffer);
|
||||
}
|
||||
|
||||
const T& value() const {
|
||||
return *((const T*) buffer);
|
||||
return *((const T*)buffer);
|
||||
}
|
||||
|
||||
template<typename Func, typename... ArgT>
|
||||
|
|
@ -119,7 +121,7 @@ public:
|
|||
|
||||
const T& value_or(const T& default_value) const {
|
||||
if (initialized) {
|
||||
return *((const T*) buffer);
|
||||
return *((const T*)buffer);
|
||||
} else {
|
||||
return default_value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,17 @@
|
|||
// Minimal freestanding replacements for <utility> (no stdlib available).
|
||||
|
||||
template<typename T>
|
||||
struct remove_reference { using type = T; };
|
||||
struct remove_reference {
|
||||
using type = T;
|
||||
};
|
||||
template<typename T>
|
||||
struct remove_reference<T&> { using type = T; };
|
||||
struct remove_reference<T&> {
|
||||
using type = T;
|
||||
};
|
||||
template<typename T>
|
||||
struct remove_reference<T&&> { using type = T; };
|
||||
struct remove_reference<T&&> {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using remove_reference_t = typename remove_reference<T>::type;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue