All `make_opaque_handle()` functions cause compiler segfault at `constexpr bool is_nothrow`; they should be changed to #define macros.

Fortune for opaque_handle's current commit: Future blessing − 末吉
master
Avril 3 years ago
parent 742aa072ec
commit e8813d52eb
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -203,6 +203,7 @@ template<typename F, typename T>
concept OpaqueHandleFunc = std::is_invocable_v<F, T*, opaque_handle_operation> concept OpaqueHandleFunc = std::is_invocable_v<F, T*, opaque_handle_operation>
&& std::is_convertible_v<std::invoke_result_t<F, T*, opaque_handle_operation>, T*>; && std::is_convertible_v<std::invoke_result_t<F, T*, opaque_handle_operation>, T*>;
//TODO: Turn all local `constexpr is_nothrow` in the following functions into #define macros. The constexpr locals being used in a local class cause the compiler to segfault for some reason...
/// Create and opaque_handle from a data pointer and a lambda which handles the copying (if possible) and deleting of the object /// Create and opaque_handle from a data pointer and a lambda which handles the copying (if possible) and deleting of the object
/// ///
@ -242,8 +243,8 @@ constexpr inline opaque_handle make_opaque_handle(T* data, const HandleF& handle
template<typename T, OpaqueHandleFunc<T> HandleF> template<typename T, OpaqueHandleFunc<T> HandleF>
constexpr inline opaque_handle make_opaque_handle(T* data, HandleF&& handler) noexcept(std::is_nothrow_move_constructible_v<HandleF>) constexpr inline opaque_handle make_opaque_handle(T* data, HandleF&& handler) noexcept(std::is_nothrow_move_constructible_v<HandleF>)
{ {
constexpr const bool is_nothrow = std::is_nothrow_invocable_v<HandleF, T*, opaque_handle_operation>; constexpr bool is_nothrow = std::is_nothrow_invocable_v<HandleF, T*, opaque_handle_operation>; //XXX: Causes segfault... TODO: turn these into a #define macro
constexpr const bool is_nothrow_ctor = std::is_nothrow_move_constructible_v<HandleF>; constexpr bool is_nothrow_ctor = std::is_nothrow_move_constructible_v<HandleF>;
struct object_handler struct object_handler
{ {

@ -30,7 +30,7 @@ static inline void print(const std::string& string)
void use_moh() void use_moh()
{ {
std::string str{"Hello from 2!"}; std::string str{"Hello from 2!"};
opaque_handle v{make_opaque_handle<std::string>(&str, [](std::string* ptr, auto op) noexcept { constexpr auto _h = [](std::string* ptr, auto op) noexcept {
if(ptr) { if(ptr) {
switch(op) { switch(op) {
case opaque_handle_operation::Clone: return new std::string(*ptr); case opaque_handle_operation::Clone: return new std::string(*ptr);
@ -38,7 +38,8 @@ void use_moh()
} }
} }
return static_cast<std::string*>(nullptr); return static_cast<std::string*>(nullptr);
})}; };
opaque_handle v{make_opaque_handle<std::string, _h>(&str)};
print(*v); print(*v);
} }

Loading…
Cancel
Save