Two small refactors
This commit is contained in:
parent
d6f6617c14
commit
e82f6e360f
@ -169,12 +169,13 @@ namespace detail {
|
||||
typename std::enable_if<!std::is_same<typename std::decay<T>::type, void>::value, int>::type = 0
|
||||
>
|
||||
class optional {
|
||||
bool holds_value = false;
|
||||
|
||||
union {
|
||||
char x;
|
||||
T uvalue;
|
||||
};
|
||||
|
||||
bool holds_value = false;
|
||||
|
||||
public:
|
||||
optional() noexcept {}
|
||||
|
||||
@ -201,7 +202,7 @@ namespace detail {
|
||||
|
||||
optional& operator=(const optional& other) {
|
||||
optional copy(other);
|
||||
swap(*this, copy);
|
||||
swap(copy);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -229,12 +230,8 @@ namespace detail {
|
||||
typename std::enable_if<!std::is_same<typename std::decay<U>::type, optional<T>>::value, int>::type = 0
|
||||
>
|
||||
optional& operator=(U&& value) {
|
||||
if(holds_value) {
|
||||
uvalue = std::forward<U>(value);
|
||||
} else {
|
||||
new (static_cast<void*>(std::addressof(uvalue))) T(std::forward<U>(value));
|
||||
holds_value = true;
|
||||
}
|
||||
optional o(std::move(value));
|
||||
swap(o);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ namespace detail {
|
||||
}
|
||||
|
||||
std::vector<stacktrace_frame> resolve_frames(const std::vector<object_frame>& frames) {
|
||||
std::vector<stacktrace_frame> trace(frames.size(), stacktrace_frame { 0, 0, UINT_LEAST32_MAX, "", "" });
|
||||
std::vector<stacktrace_frame> trace(frames.size(), null_frame);
|
||||
#if defined(CPPTRACE_GET_SYMBOLS_WITH_LIBDL) \
|
||||
|| defined(CPPTRACE_GET_SYMBOLS_WITH_DBGHELP) \
|
||||
|| defined(CPPTRACE_GET_SYMBOLS_WITH_LIBBACKTRACE)
|
||||
@ -87,7 +87,7 @@ namespace detail {
|
||||
|| defined(CPPTRACE_GET_SYMBOLS_WITH_ADDR2LINE)
|
||||
auto dlframes = get_frames_object_info(frames);
|
||||
#endif
|
||||
std::vector<stacktrace_frame> trace(frames.size(), stacktrace_frame { 0, 0, UINT_LEAST32_MAX, "", "" });
|
||||
std::vector<stacktrace_frame> trace(frames.size(), null_frame);
|
||||
#ifdef CPPTRACE_GET_SYMBOLS_WITH_LIBDL
|
||||
apply_trace(trace, libdl::resolve_frames(frames));
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user