chore: enable C++23 and prefer std::expected (#6693)

This commit is contained in:
pajlada
2025-12-30 13:12:33 +01:00
committed by GitHub
parent fe3c089fd5
commit b4c5b8e3bd
3 changed files with 25 additions and 5 deletions
+2
View File
@@ -74,6 +74,8 @@
- Dev: Added Clazy linting in CI. (#6623)
- Dev: Added custom clang-tidy module linting in CI. (#6626)
- Dev: CMake option `USE_ALTERNATE_LINKER` now errors if the given linker can't be found. (#6692)
- Dev: Enable C++ 23. (#6693)
- Dev: Prefer `std::expected` over `nonstd::expected_lite`. (#6693)
- Dev: Moved Twitch PubSub to liveupdates. (#6638)
## 2.5.4
+1 -1
View File
@@ -270,7 +270,7 @@ else ()
string(TIMESTAMP cmake_gen_date "%Y-%m-%d")
endif ()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Generate resource files
+21 -3
View File
@@ -1,6 +1,12 @@
#pragma once
#include <version>
#if __cpp_lib_expected >= 202202L
# include <expected>
#else
# include <nonstd/expected.hpp>
#endif
#include <type_traits>
@@ -8,17 +14,29 @@ class QString;
namespace chatterino {
#if __cpp_lib_expected >= 202202L
template <typename T, typename E>
using Expected = std::expected<T, E>;
// convenience function from nonstd/expected.hpp
template <typename E>
constexpr std::unexpected<std::decay_t<E>> makeUnexpected(E &&value)
{
return std::unexpected<std::decay_t<E>>(std::forward<E>(value));
}
#else
template <typename T, typename E>
using Expected = nonstd::expected_lite::expected<T, E>;
template <typename T>
using ExpectedStr = Expected<T, QString>;
// convenience function from nonstd/expected.hpp
template <typename E>
constexpr nonstd::unexpected<std::decay_t<E>> makeUnexpected(E &&value)
{
return nonstd::unexpected<std::decay_t<E>>(std::forward<E>(value));
}
#endif
template <typename T>
using ExpectedStr = Expected<T, QString>;
} // namespace chatterino