mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
fix: [imp] dataof/countof's SFINAE may be invalid
This commit is contained in:
parent
08b6649946
commit
bad1ff4696
@ -71,9 +71,11 @@ struct trait<C, false, true> {
|
|||||||
|
|
||||||
} // namespace detail_countof
|
} // namespace detail_countof
|
||||||
|
|
||||||
template <typename C, typename R = detail_countof::trait<C>>
|
template <typename C,
|
||||||
constexpr auto countof(C const &c) noexcept(noexcept(R::countof(c))) {
|
typename T = detail_countof::trait<C>,
|
||||||
return R::countof(c);
|
typename R = decltype(T::countof(std::declval<C const &>()))>
|
||||||
|
constexpr R countof(C const &c) noexcept(noexcept(T::countof(c))) {
|
||||||
|
return T::countof(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBIMP_NAMESPACE_END_
|
LIBIMP_NAMESPACE_END_
|
||||||
|
|||||||
@ -80,13 +80,19 @@ struct trait<C, false, false> {
|
|||||||
constexpr static T const *dataof(std::initializer_list<T> il) noexcept {
|
constexpr static T const *dataof(std::initializer_list<T> il) noexcept {
|
||||||
return il.begin();
|
return il.begin();
|
||||||
}
|
}
|
||||||
|
template <typename T>
|
||||||
|
constexpr static T const *dataof(T const *p) noexcept {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail_dataof
|
} // namespace detail_dataof
|
||||||
|
|
||||||
template <typename T, typename R = detail_dataof::trait<std::remove_cv_t<std::remove_reference_t<T>>>>
|
template <typename C,
|
||||||
constexpr auto dataof(T &&c) noexcept(noexcept(R::dataof(std::forward<T>(c)))) {
|
typename T = detail_dataof::trait<std::remove_cv_t<std::remove_reference_t<C>>>,
|
||||||
return R::dataof(std::forward<T>(c));
|
typename R = decltype(T::dataof(std::declval<C>()))>
|
||||||
|
constexpr R dataof(C &&c) noexcept(noexcept(T::dataof(std::forward<C>(c)))) {
|
||||||
|
return T::dataof(std::forward<C>(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBIMP_NAMESPACE_END_
|
LIBIMP_NAMESPACE_END_
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user