Skip to content

Commit

Permalink
Prevent implementations of Result<bool,..>
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing committed Jun 28, 2021
1 parent 3fd7001 commit f5f0675
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/common/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Result
: _result(std::move(value))
, _isError(false)
{
static_assert(!std::is_same<T, bool>::value, "Bool is not supported as this class overrides the bool operator");
}
// TODO: This doesn't work if T and Error are too similar
Result(Error error)
Expand Down
4 changes: 2 additions & 2 deletions src/common/vfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Optional<Vfs::Mode> Vfs::modeFromString(const QString &str)
return {};
}

Result<bool, QString> Vfs::checkAvailability(const QString &path)
Result<void, QString> Vfs::checkAvailability(const QString &path)
{
#ifdef Q_OS_WIN
const auto mode = bestAvailableVfsMode();
Expand All @@ -84,7 +84,7 @@ Result<bool, QString> Vfs::checkAvailability(const QString &path)
#else
Q_UNUSED(path);
#endif
return true;
return {};
}

void Vfs::start(const VfsSetupParams &params)
Expand Down
2 changes: 1 addition & 1 deletion src/common/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class OCSYNC_EXPORT Vfs : public QObject
static QString modeToString(Mode mode);
static Optional<Mode> modeFromString(const QString &str);

static Result<bool, QString> checkAvailability(const QString &path);
static Result<void, QString> checkAvailability(const QString &path);

enum class AvailabilityError
{
Expand Down

0 comments on commit f5f0675

Please sign in to comment.