tests: Convert ExpressionMatchTests into a GTest-based test case
[quassel.git] / src / common / util.h
index ba73f4d..cead16f 100644 (file)
@@ -46,7 +46,7 @@ COMMON_EXPORT QString secondsToString(int timeInSeconds);
  *  \param codec The text codec we use if the input is not utf8
  *  \return The decoded string.
  */
-COMMON_EXPORT QString decodeString(const QByteArray &input, QTextCodec *codec = 0);
+COMMON_EXPORT QString decodeString(const QByteArray &input, QTextCodec *codec = nullptr);
 
 COMMON_EXPORT uint editingDistance(const QString &s1, const QString &s2);
 
@@ -105,3 +105,27 @@ COMMON_EXPORT QString tryFormatUnixEpoch(const QString &possibleEpochDate,
  * @return Date/time in ISO 8601 format with timezone offset
  */
 COMMON_EXPORT QString formatDateTimeToOffsetISO(const QDateTime &dateTime);
+
+namespace detail {
+
+template<typename ...Args>
+struct SelectOverloadHelper
+{
+    template <typename R, typename C>
+    constexpr auto operator()(R(C::*func)(Args...)) const noexcept -> decltype(func) { return func; }
+};
+
+}  // detail
+
+/**
+ * Helper for resolving ambiguous overloads when using the member function-based connect syntax.
+ *
+ * Example usage:
+ * @code
+ * connect(this, selectOverload<int, QString>(&MyClass::mySignal), other, &Other::mySlot);
+ * @endcode
+ *
+ * @tparam Args Argument types of the desired signature
+ */
+template<typename ...Args>
+constexpr Q_DECL_UNUSED detail::SelectOverloadHelper<Args...> selectOverload = {};