diff --git a/CMakeLists.txt b/CMakeLists.txt index fb3d683..6dddc83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,13 @@ FetchContent_Declare( GIT_SHALLOW TRUE ) +FetchContent_Declare( + tl_expected + GIT_REPOSITORY https://github.com/TartanLlama/expected.git + GIT_TAG v1.1.0 +) +FetchContent_MakeAvailable(tl_expected) + # c++20 format library, super usefull, super fast set(FMT_TEST OFF CACHE INTERNAL "disabling fmt tests") set(FMT_FUZZ OFF CACHE INTERNAL "disabling fmt fuzz") @@ -43,7 +50,7 @@ FetchContent_Declare(fmt URL https://github.com/fmtlib/fmt/archive/refs/tags/10.2.1.zip URL_MD5 1bba4e8bdd7b0fa98f207559ffa380a3 ) -FetchContent_MakeAvailable(fmt spdlog) +FetchContent_MakeAvailable(fmt spdlog tl_expected) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) # add_compile_definitions(BOOST_ASIO_ENABLE_HANDLER_TRACKING) diff --git a/config.hpp b/config.hpp index c73e390..8f1867f 100644 --- a/config.hpp +++ b/config.hpp @@ -4,16 +4,34 @@ #include #include +#if __has_include() #include +#elif __has_include() +#include +#else +#error "No expected implementation available" +#endif namespace ranczo { +#if __has_include() template < typename T > using expected = std::expected< T, boost::system::error_code >; - template < typename T > using unexpected = std::unexpected< T >; +#elif __has_include() +template < typename T > +using expected = tl::expected< T, boost::system::error_code >; + +template < typename T > +using unexpected = tl::unexpected< T >; + +#else +#error "No expected implementation available" +#endif + + template < typename T > using awaitable_expected = boost::asio::awaitable< expected< T > >;