mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 16:55:36 +08:00
Use if constexpr (C++17 feature)
This commit is contained in:
@@ -151,12 +151,12 @@ namespace BlackMisc
|
||||
|
||||
protected:
|
||||
//! Efficiently compare addresses of two objects. Return false if types are not compatible.
|
||||
//! @{
|
||||
template <typename T, typename U, std::enable_if_t<TIsEqualityComparable<const T *, const U *>::value, int> = 0>
|
||||
static bool equalPointers(const T *a, const U *b) { return a == b; }
|
||||
template <typename T, typename U, std::enable_if_t<! TIsEqualityComparable<const T *, const U *>::value, int> = 0>
|
||||
static bool equalPointers(const T *, const U *) { return false; }
|
||||
//! @}
|
||||
template <typename T, typename U>
|
||||
static bool equalPointers(const T *a, const U *b)
|
||||
{
|
||||
if constexpr (TIsEqualityComparable<const T *, const U *>::value) { return a == b; }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
private:
|
||||
Derived &derived() { return static_cast<Derived &>(*this); }
|
||||
|
||||
Reference in New Issue
Block a user