namespace art { // Implementation details for some template querying. Don't look inside if you hate templates. namespace detail { template <typename T> typename std::remove_reference<T>::type& FakeReference();
// SupportsInsertionOperator<T, TStream>::value will evaluate to a boolean, // whose value is true if the TStream class supports the << operator against T, // and false otherwise. template <typename T2, typename TStream2 = std::ostream> struct SupportsInsertionOperator { private: template <typename TStream, typename T> static std::true_type InsertionOperatorTest(TStream& os, const T& value,
std::remove_reference<decltype(os << value)>* = 0); // NOLINT [whitespace/operators] [3]
public: static constexpr bool value =
decltype(EqualityOperatorTest(std::declval<TLeft>(), std::declval<TRight>()))::value;
};
// Partial specialization when TLeft/TRight are both floating points. // This is a work-around because decltype(floatvar1 == floatvar2) // will not compile with clang: // error: comparing floating point with == or != is unsafe [-Werror,-Wfloat-equal] template <typename TLeft, typename TRight> struct SupportsEqualityOperatorImpl<TLeft, TRight, true> { static constexpr bool value = true;
};
// SupportsEqualityOperatorImpl<T1, T2>::value will evaluate to a boolean, // whose value is true if T1 can be compared against T2 with ==, // and false otherwise. template <typename TLeft, typename TRight = TLeft> struct SupportsEqualityOperator : // NOLINT [whitespace/labels] [4]
SupportsEqualityOperatorImpl<TLeft, TRight,
std::is_floating_point<TLeft>::value
&& std::is_floating_point<TRight>::value> {
};
// Convert any kind of type to an std::string, even if there's no // serialization support for it. Unknown types get converted to an // an arbitrary value. // // Meant for printing user-visible errors or unit test failures only. template <typename T>
std::string ToStringAny(const T& value, typename std::enable_if<
SupportsInsertionOperator<T>::value>::type* = nullptr) {
std::stringstream stream;
stream << value; return stream.str();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.