diff --git a/include/libimp/horrible_cast.h b/include/libimp/horrible_cast.h index 88520c6..cce6ef7 100644 --- a/include/libimp/horrible_cast.h +++ b/include/libimp/horrible_cast.h @@ -12,14 +12,20 @@ LIBIMP_NAMESPACE_BEG_ +namespace detail_horrible_cast { + +template +union temp { + std::decay_t in; + T out; +}; + +} // namespace detail_horrible_cast + template constexpr auto horrible_cast(U &&in) noexcept -> std::enable_if_t<(sizeof(T) == sizeof(std::decay_t)), T> { - union { - std::decay_t in; - T out; - } u {std::forward(in)}; - return u.out; + return detail_horrible_cast::temp>{std::forward(in)}.out; } LIBIMP_NAMESPACE_END_ diff --git a/include/libimp/result.h b/include/libimp/result.h index e72052b..81f94c8 100644 --- a/include/libimp/result.h +++ b/include/libimp/result.h @@ -154,7 +154,7 @@ LIBIMP_NAMESPACE_END_ template struct fmt::formatter<::LIBIMP_::result> { - constexpr auto parse(format_parse_context& ctx) { + constexpr auto parse(format_parse_context& ctx) const { return ctx.end(); } diff --git a/src/libimp/CMakeLists.txt b/src/libimp/CMakeLists.txt index 65e3405..4e5fc42 100644 --- a/src/libimp/CMakeLists.txt +++ b/src/libimp/CMakeLists.txt @@ -1,5 +1,10 @@ project(imp) +if(NOT MSVC) + add_compile_options( + -Wno-attributes) +endif() + aux_source_directory(${LIBIPC_PROJECT_DIR}/src/libimp SRC_FILES) file(GLOB HEAD_FILES diff --git a/src/libipc/CMakeLists.txt b/src/libipc/CMakeLists.txt index 60007c1..7eed20b 100644 --- a/src/libipc/CMakeLists.txt +++ b/src/libipc/CMakeLists.txt @@ -1,5 +1,10 @@ project(ipc) +if(NOT MSVC) + add_compile_options( + -Wno-attributes) +endif() + aux_source_directory(${LIBIPC_PROJECT_DIR}/src/libipc SRC_FILES) file(GLOB HEAD_FILES