mirror of
https://github.com/Naios/continuable.git
synced 2026-02-16 23:29:48 +08:00
Fix clang and GCC build errors
This commit is contained in:
parent
19d4bd97dd
commit
140627cfd2
@ -181,7 +181,7 @@ class expected
|
|||||||
template <typename V>
|
template <typename V>
|
||||||
expected(V&& value, detail::slot_t const slot) {
|
expected(V&& value, detail::slot_t const slot) {
|
||||||
using type = std::decay_t<decltype(value)>;
|
using type = std::decay_t<decltype(value)>;
|
||||||
new (&storage_) type(std::forward<V>(value));
|
new (&this->storage_) type(std::forward<V>(value));
|
||||||
set(slot);
|
set(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
template <typename V>
|
template <typename V>
|
||||||
void visit(V&& visitor) {
|
void visit(V&& visitor) {
|
||||||
switch (slot_) {
|
switch (this->slot_) {
|
||||||
case detail::slot_t::value:
|
case detail::slot_t::value:
|
||||||
return std::forward<V>(visitor)(cast<T>());
|
return std::forward<V>(visitor)(cast<T>());
|
||||||
case detail::slot_t::error:
|
case detail::slot_t::error:
|
||||||
@ -271,7 +271,7 @@ private:
|
|||||||
}
|
}
|
||||||
template <typename V>
|
template <typename V>
|
||||||
void visit(V&& visitor) const {
|
void visit(V&& visitor) const {
|
||||||
switch (slot_) {
|
switch (this->slot_) {
|
||||||
case detail::slot_t::value:
|
case detail::slot_t::value:
|
||||||
return std::forward<V>(visitor)(cast<T>());
|
return std::forward<V>(visitor)(cast<T>());
|
||||||
case detail::slot_t::error:
|
case detail::slot_t::error:
|
||||||
@ -289,20 +289,19 @@ private:
|
|||||||
template <typename V>
|
template <typename V>
|
||||||
V& cast() noexcept {
|
V& cast() noexcept {
|
||||||
assert(!is_empty());
|
assert(!is_empty());
|
||||||
return *reinterpret_cast<V*>(&storage_);
|
return *reinterpret_cast<V*>(&this->storage_);
|
||||||
}
|
}
|
||||||
template <typename V>
|
template <typename V>
|
||||||
V const& cast() const noexcept {
|
V const& cast() const noexcept {
|
||||||
assert(!is_empty());
|
assert(!is_empty());
|
||||||
return *reinterpret_cast<V const*>(&storage_);
|
return *reinterpret_cast<V const*>(&this->storage_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename V>
|
template <typename V>
|
||||||
void init(V&& value) {
|
void init(V&& value) {
|
||||||
assert(is_empty());
|
assert(is_empty());
|
||||||
using type = std::decay_t<decltype(value)>;
|
using type = std::decay_t<decltype(value)>;
|
||||||
auto storage = &storage_;
|
new (&this->storage_) type(std::forward<V>(value));
|
||||||
new (storage) type(std::forward<V>(value));
|
|
||||||
}
|
}
|
||||||
void destroy() {
|
void destroy() {
|
||||||
weak_destroy();
|
weak_destroy();
|
||||||
@ -322,13 +321,13 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
detail::slot_t get() const noexcept {
|
detail::slot_t get() const noexcept {
|
||||||
return slot_;
|
return this->slot_;
|
||||||
}
|
}
|
||||||
bool is(detail::slot_t const slot) const noexcept {
|
bool is(detail::slot_t const slot) const noexcept {
|
||||||
return get() == slot;
|
return get() == slot;
|
||||||
}
|
}
|
||||||
void set(detail::slot_t const slot) {
|
void set(detail::slot_t const slot) {
|
||||||
slot_ = slot;
|
this->slot_ = slot;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace util
|
} // namespace util
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user