aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/e2ee/e2ee.h5
-rw-r--r--lib/events/encryptionevent.cpp4
-rw-r--r--lib/jobs/basejob.cpp20
-rw-r--r--lib/quotient_common.h27
4 files changed, 21 insertions, 35 deletions
diff --git a/lib/e2ee/e2ee.h b/lib/e2ee/e2ee.h
index f97eb27a..1efd0f16 100644
--- a/lib/e2ee/e2ee.h
+++ b/lib/e2ee/e2ee.h
@@ -37,8 +37,9 @@ constexpr auto MegolmV1AesSha2AlgoKey = "m.megolm.v1.aes-sha2"_ls;
inline bool isSupportedAlgorithm(const QString& algorithm)
{
- static constexpr auto SupportedAlgorithms =
- make_array(OlmV1Curve25519AesSha2AlgoKey, MegolmV1AesSha2AlgoKey);
+ static constexpr std::array SupportedAlgorithms {
+ OlmV1Curve25519AesSha2AlgoKey, MegolmV1AesSha2AlgoKey
+ };
return std::find(SupportedAlgorithms.cbegin(), SupportedAlgorithms.cend(),
algorithm)
!= SupportedAlgorithms.cend();
diff --git a/lib/events/encryptionevent.cpp b/lib/events/encryptionevent.cpp
index 6e994cd4..eb15f38e 100644
--- a/lib/events/encryptionevent.cpp
+++ b/lib/events/encryptionevent.cpp
@@ -9,9 +9,7 @@
#include <array>
namespace Quotient {
-static const std::array<QString, 1> encryptionStrings = {
- { MegolmV1AesSha2AlgoKey }
-};
+static constexpr std::array encryptionStrings { MegolmV1AesSha2AlgoKey };
template <>
struct JsonConverter<EncryptionType> {
diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp
index fe70911e..da645a2d 100644
--- a/lib/jobs/basejob.cpp
+++ b/lib/jobs/basejob.cpp
@@ -138,9 +138,8 @@ public:
QTimer timer;
QTimer retryTimer;
- static constexpr std::array<const JobTimeoutConfig, 3> errorStrategy {
- { { 90s, 5s }, { 90s, 10s }, { 120s, 30s } }
- };
+ static constexpr auto errorStrategy = std::to_array<const JobTimeoutConfig>(
+ { { 90s, 5s }, { 90s, 10s }, { 120s, 30s } });
int maxRetries = int(errorStrategy.size());
int retriesTaken = 0;
@@ -152,10 +151,8 @@ public:
[[nodiscard]] QString dumpRequest() const
{
- // FIXME: use std::array {} when Apple stdlib gets deduction guides for it
- static const auto verbs =
- make_array(QStringLiteral("GET"), QStringLiteral("PUT"),
- QStringLiteral("POST"), QStringLiteral("DELETE"));
+ static const std::array verbs { "GET"_ls, "PUT"_ls, "POST"_ls,
+ "DELETE"_ls };
const auto verbWord = verbs.at(size_t(verb));
return verbWord % ' '
% (reply ? reply->url().toString(QUrl::RemoveQuery)
@@ -748,11 +745,14 @@ QString BaseJob::statusCaption() const
}
}
-int BaseJob::error() const { return d->status.code; }
+int BaseJob::error() const {
+ return d->status.code; }
-QString BaseJob::errorString() const { return d->status.message; }
+QString BaseJob::errorString() const {
+ return d->status.message; }
-QUrl BaseJob::errorUrl() const { return d->errorUrl; }
+QUrl BaseJob::errorUrl() const {
+ return d->errorUrl; }
void BaseJob::setStatus(Status s)
{
diff --git a/lib/quotient_common.h b/lib/quotient_common.h
index 8bcd5ca6..136e9f79 100644
--- a/lib/quotient_common.h
+++ b/lib/quotient_common.h
@@ -41,7 +41,6 @@
Q_ENUM_NS_IMPL(Enum) \
Q_FLAG_NS(Flags)
-// Apple Clang hasn't caught up with explicit(bool) yet
#if __cpp_conditional_explicit >= 201806L
#define QUO_IMPLICIT explicit(false)
#else
@@ -54,19 +53,6 @@
namespace Quotient {
Q_NAMESPACE_EXPORT(QUOTIENT_API)
-// std::array {} needs explicit template parameters on macOS because
-// Apple stdlib doesn't have deduction guides for std::array. C++20 has
-// to_array() but that can't be borrowed, this time because of MSVC:
-// https://developercommunity.visualstudio.com/t/vc-ice-p1-initc-line-3652-from-stdto-array/1464038
-// Therefore a simpler (but also slightly more wobbly - it resolves the element
-// type using std::common_type<>) make_array facility is implemented here.
-template <typename... Ts>
-constexpr auto make_array(Ts&&... items)
-{
- return std::array<std::common_type_t<Ts...>, sizeof...(items)>(
- { std::forward<Ts>(items)... });
-}
-
// TODO: code like this should be generated from the CS API definition
//! \brief Membership states
@@ -87,9 +73,10 @@ enum class Membership : unsigned int {
};
QUO_DECLARE_FLAGS_NS(MembershipMask, Membership)
-constexpr auto MembershipStrings = make_array(
- // The order MUST be the same as the order in the original enum
- "join", "leave", "invite", "knock", "ban");
+constexpr std::array MembershipStrings {
+ // The order MUST be the same as the order in the Membership enum
+ "join", "leave", "invite", "knock", "ban"
+};
//! \brief Local user join-state names
//!
@@ -105,10 +92,10 @@ enum class JoinState : std::underlying_type_t<Membership> {
};
QUO_DECLARE_FLAGS_NS(JoinStates, JoinState)
-[[maybe_unused]] constexpr auto JoinStateStrings = make_array(
+[[maybe_unused]] constexpr std::array JoinStateStrings {
MembershipStrings[0], MembershipStrings[1], MembershipStrings[2],
MembershipStrings[3] /* same as MembershipStrings, sans "ban" */
-);
+};
//! \brief Network job running policy flags
//!
@@ -135,7 +122,7 @@ enum RoomType {
};
Q_ENUM_NS(RoomType)
-[[maybe_unused]] constexpr auto RoomTypeStrings = make_array("m.space");
+[[maybe_unused]] constexpr std::array RoomTypeStrings { "m.space" };
} // namespace Quotient
Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::MembershipMask)