diff --git a/include/opaque.hh b/include/opaque.hh index 5c868fe..fd5460e 100644 --- a/include/opaque.hh +++ b/include/opaque.hh @@ -203,6 +203,7 @@ template concept OpaqueHandleFunc = std::is_invocable_v && std::is_convertible_v, 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 /// @@ -242,8 +243,8 @@ constexpr inline opaque_handle make_opaque_handle(T* data, const HandleF& handle template HandleF> constexpr inline opaque_handle make_opaque_handle(T* data, HandleF&& handler) noexcept(std::is_nothrow_move_constructible_v) { - constexpr const bool is_nothrow = std::is_nothrow_invocable_v; - constexpr const bool is_nothrow_ctor = std::is_nothrow_move_constructible_v; + constexpr bool is_nothrow = std::is_nothrow_invocable_v; //XXX: Causes segfault... TODO: turn these into a #define macro + constexpr bool is_nothrow_ctor = std::is_nothrow_move_constructible_v; struct object_handler { diff --git a/src/main.cpp b/src/main.cpp index ba07755..d514d9e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,7 @@ static inline void print(const std::string& string) void use_moh() { std::string str{"Hello from 2!"}; - opaque_handle v{make_opaque_handle(&str, [](std::string* ptr, auto op) noexcept { + constexpr auto _h = [](std::string* ptr, auto op) noexcept { if(ptr) { switch(op) { case opaque_handle_operation::Clone: return new std::string(*ptr); @@ -38,7 +38,8 @@ void use_moh() } } return static_cast(nullptr); - })}; + }; + opaque_handle v{make_opaque_handle(&str)}; print(*v); }