Fix another g++-4.9 CE.
GitOrigin-RevId: a33df8605db518fb5dfea2f542094af6977c2053
This commit is contained in:
parent
8c3eb953ae
commit
a9ded5b498
@ -64,14 +64,21 @@ class ConstAs {
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// no std::is_trivially_copyable in libstdc++ before 5.0
|
||||
#if __GLIBCXX__
|
||||
#define TD_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
|
||||
#else
|
||||
#define TD_IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value
|
||||
#endif
|
||||
|
||||
template <class ToT, class FromT,
|
||||
std::enable_if_t<std::is_trivially_copyable<ToT>::value && std::is_trivially_copyable<FromT>::value, int> = 0>
|
||||
std::enable_if_t<TD_IS_TRIVIALLY_COPYABLE(ToT) && TD_IS_TRIVIALLY_COPYABLE(FromT), int> = 0>
|
||||
detail::As<ToT> as(FromT *from) {
|
||||
return detail::As<ToT>(from);
|
||||
}
|
||||
|
||||
template <class ToT, class FromT,
|
||||
std::enable_if_t<std::is_trivially_copyable<ToT>::value && std::is_trivially_copyable<FromT>::value, int> = 0>
|
||||
std::enable_if_t<TD_IS_TRIVIALLY_COPYABLE(ToT) && TD_IS_TRIVIALLY_COPYABLE(FromT), int> = 0>
|
||||
const detail::ConstAs<ToT> as(const FromT *from) {
|
||||
return detail::ConstAs<ToT>(from);
|
||||
}
|
||||
|
Reference in New Issue
Block a user