mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
fix: [vs2015] error C3250: 'u': declaration is not allowed in 'constexpr' function body
This commit is contained in:
parent
d129e6221a
commit
c1557a72ac
@ -12,14 +12,20 @@
|
||||
|
||||
LIBIMP_NAMESPACE_BEG_
|
||||
|
||||
namespace detail_horrible_cast {
|
||||
|
||||
template <typename T, typename U>
|
||||
union temp {
|
||||
std::decay_t<U> in;
|
||||
T out;
|
||||
};
|
||||
|
||||
} // namespace detail_horrible_cast
|
||||
|
||||
template <typename T, typename U>
|
||||
constexpr auto horrible_cast(U &&in) noexcept
|
||||
-> std::enable_if_t<(sizeof(T) == sizeof(std::decay_t<U>)), T> {
|
||||
union {
|
||||
std::decay_t<U> in;
|
||||
T out;
|
||||
} u {std::forward<U>(in)};
|
||||
return u.out;
|
||||
return detail_horrible_cast::temp<T, std::decay_t<U>>{std::forward<U>(in)}.out;
|
||||
}
|
||||
|
||||
LIBIMP_NAMESPACE_END_
|
||||
|
||||
@ -154,7 +154,7 @@ LIBIMP_NAMESPACE_END_
|
||||
|
||||
template <typename T, typename D>
|
||||
struct fmt::formatter<::LIBIMP_::result<T, D>> {
|
||||
constexpr auto parse(format_parse_context& ctx) {
|
||||
constexpr auto parse(format_parse_context& ctx) const {
|
||||
return ctx.end();
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user