mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06: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
|
||||
|
||||
template <typename C, typename R = detail_countof::trait<C>>
|
||||
constexpr auto countof(C const &c) noexcept(noexcept(R::countof(c))) {
|
||||
return R::countof(c);
|
||||
template <typename C,
|
||||
typename T = detail_countof::trait<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_
|
||||
|
||||
@ -80,13 +80,19 @@ struct trait<C, false, false> {
|
||||
constexpr static T const *dataof(std::initializer_list<T> il) noexcept {
|
||||
return il.begin();
|
||||
}
|
||||
template <typename T>
|
||||
constexpr static T const *dataof(T const *p) noexcept {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail_dataof
|
||||
|
||||
template <typename T, typename R = detail_dataof::trait<std::remove_cv_t<std::remove_reference_t<T>>>>
|
||||
constexpr auto dataof(T &&c) noexcept(noexcept(R::dataof(std::forward<T>(c)))) {
|
||||
return R::dataof(std::forward<T>(c));
|
||||
template <typename C,
|
||||
typename T = detail_dataof::trait<std::remove_cv_t<std::remove_reference_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_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user