diff --git a/CMakeLists.txt b/CMakeLists.txt index fca77b6ad..66242e950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,6 @@ cmake_dependent_option( stlab.coverage "Enable binary instrumentation to collect test coverage information in the DEBUG configuration" OFF PROJECT_IS_TOP_LEVEL OFF ) -stlab_check_disfunctional_variant_optional(STLAB_DEFAULT_USE_BOOST_CPP17_SHIMS) -option( STLAB_USE_BOOST_CPP17_SHIMS "Use variant and optional from Boost instead of std. Useful for non-conforming compilers." ${STLAB_DEFAULT_USE_BOOST_CPP17_SHIMS} ) stlab_check_disfunctional_coroutines(STLAB_DEFAULT_NO_STD_COROUTINES) option( STLAB_NO_STD_COROUTINES "Suppress usage of standard coroutines. Useful for non-conforming compilers." ${STLAB_DEFAULT_NO_STD_COROUTINES} ) stlab_detect_thread_system(STLAB_DEFAULT_THREAD_SYSTEM) @@ -35,10 +33,6 @@ if( BUILD_TESTING AND NOT Boost_unit_test_framework_FOUND ) message( SEND_ERROR "BUILD_TESTING is enabled, but an installation of Boost.Test was not found." ) endif() -if( STLAB_USE_BOOST_CPP17_SHIMS AND NOT Boost_FOUND ) - message( SEND_ERROR "STLAB_USE_BOOST_CPP17_SHIMS is enabled, but a Boost installation was not found." ) -endif() - if( (NOT STLAB_THREAD_SYSTEM STREQUAL "none") AND NOT Threads_FOUND ) message( SEND_ERROR "STLAB_THREAD_SYSTEM is not \"none\", but a thread system was not found." ) endif() @@ -89,10 +83,6 @@ target_compile_definitions( stlab INTERFACE $<$:NOMINMAX> add_subdirectory( stlab ) -if ( STLAB_USE_BOOST_CPP17_SHIMS ) - target_link_libraries( stlab INTERFACE Boost::boost ) -endif() - if ( NOT STLAB_THREAD_SYSTEM STREQUAL "none" ) target_link_libraries( stlab INTERFACE Threads::Threads ) endif() @@ -109,7 +99,6 @@ elseif (STLAB_MAIN_EXECUTOR STREQUAL "qt6") target_link_libraries( stlab INTERFACE Qt6::Core ) endif() -message(STATUS "stlab: Use Boost C++17 Shims: ${STLAB_USE_BOOST_CPP17_SHIMS}") message(STATUS "stlab: Disable Coroutines: ${STLAB_DEFAULT_NO_STD_COROUTINES}") message(STATUS "stlab: Thread System: ${STLAB_THREAD_SYSTEM}") message(STATUS "stlab: Task System: ${STLAB_TASK_SYSTEM}") diff --git a/cmake/StlabUtil.cmake b/cmake/StlabUtil.cmake index b5bba2da5..35fdb665e 100644 --- a/cmake/StlabUtil.cmake +++ b/cmake/StlabUtil.cmake @@ -4,30 +4,6 @@ include( CheckCXXSymbolExists ) include( CheckCXXSourceRuns ) -# Determine if the selected C++ compiler has functional versions of -# 'std::variant' and 'std::optional'. Set the specified 'result_var' to 'TRUE' -# if they are determined to be disfunctional and 'FALSE' otherwise. Note that -# this check consists of a smoke test and does not check all the ways these -# library components may be deficient. -function( stlab_check_disfunctional_variant_optional result_var ) - check_cxx_source_runs( " - #include - #include - - int main() { - std::optional op = 3; - op = std::nullopt; - - std::variant v = 12; - return 0; - }" STLAB_HAVE_FUNCTIONAL_VARIANT_OPTIONAL ) - if( STLAB_HAVE_FUNCTIONAL_VARIANT_OPTIONAL ) - set( ${result_var} FALSE PARENT_SCOPE ) - else() - set( ${result_var} TRUE PARENT_SCOPE ) - endif() -endfunction() - # Determine if the selected C++ compiler has functional coroutines. Set the # specified 'result_var' to 'TRUE' if they are determined to be disfunctional # and 'FALSE' otherwise. Note that this check consists of a smoke test and does diff --git a/cmake/stlabConfig.cmake.in b/cmake/stlabConfig.cmake.in index 394a8d0b8..d66157c9b 100644 --- a/cmake/stlabConfig.cmake.in +++ b/cmake/stlabConfig.cmake.in @@ -1,9 +1,5 @@ include( CMakeFindDependencyMacro ) -if ( @STLAB_USE_BOOST_CPP17_SHIMS@ ) - find_dependency( Boost 1.74.0 ) -endif() - if ( @STLAB_TASK_SYSTEM@ STREQUAL "libdispatch" ) find_dependency( libdispatch ) endif() diff --git a/docs/README.md b/docs/README.md index 3fd0493ff..85da08f83 100644 --- a/docs/README.md +++ b/docs/README.md @@ -68,7 +68,6 @@ Specify the following options: STLAB_NO_STD_COROUTINES ON STLAB_TASK_SYSTEM portable STLAB_THREAD_SYSTEM pthread - STLAB_USE_BOOST_CPP17_SHIMS OFF stlab.coverage OFF ``` diff --git a/docs/libraries/concurrency/future.hpp/future3CT2C20enable_if_.6354105c/m_error.md b/docs/libraries/concurrency/future.hpp/future3CT2C20enable_if_.6354105c/m_error.md index 6c02d5428..7ee024e10 100644 --- a/docs/libraries/concurrency/future.hpp/future3CT2C20enable_if_.6354105c/m_error.md +++ b/docs/libraries/concurrency/future.hpp/future3CT2C20enable_if_.6354105c/m_error.md @@ -7,10 +7,10 @@ tags: - method defined_in_file: concurrency/future.hpp overloads: - stlab::optional error() const &: + std::optional error() const &: annotation: - deprecated (Use exception() instead) description: __OPTIONAL__ return: __OPTIONAL__ - signature_with_names: stlab::optional error() const & + signature_with_names: std::optional error() const & --- diff --git a/docs/libraries/concurrency/future.hpp/future3CT2C20enable_if_.e055d50a/m_error.md b/docs/libraries/concurrency/future.hpp/future3CT2C20enable_if_.e055d50a/m_error.md index aa1274a93..ed3d12513 100644 --- a/docs/libraries/concurrency/future.hpp/future3CT2C20enable_if_.e055d50a/m_error.md +++ b/docs/libraries/concurrency/future.hpp/future3CT2C20enable_if_.e055d50a/m_error.md @@ -7,12 +7,12 @@ tags: - method defined_in_file: concurrency/future.hpp overloads: - stlab::optional error() const &: + std::optional error() const &: annotation: - deprecated (Use exception() instead) description: Iff an error occurred, returns the stored exception pointer. return: __OPTIONAL__ - signature_with_names: stlab::optional error() const & + signature_with_names: std::optional error() const & --- Returns a potentially stored exception pointer. This function will be removed in future versions of the library. Use `exception()` instead. diff --git a/docs/libraries/concurrency/future.hpp/future3Cvoid2C20void3E/m_error.md b/docs/libraries/concurrency/future.hpp/future3Cvoid2C20void3E/m_error.md index 6c02d5428..7ee024e10 100644 --- a/docs/libraries/concurrency/future.hpp/future3Cvoid2C20void3E/m_error.md +++ b/docs/libraries/concurrency/future.hpp/future3Cvoid2C20void3E/m_error.md @@ -7,10 +7,10 @@ tags: - method defined_in_file: concurrency/future.hpp overloads: - stlab::optional error() const &: + std::optional error() const &: annotation: - deprecated (Use exception() instead) description: __OPTIONAL__ return: __OPTIONAL__ - signature_with_names: stlab::optional error() const & + signature_with_names: std::optional error() const & --- diff --git a/docs/libraries/concurrency/future/future/error.md b/docs/libraries/concurrency/future/future/error.md index 5384f7e4b..1acacbf08 100644 --- a/docs/libraries/concurrency/future/future/error.md +++ b/docs/libraries/concurrency/future/future/error.md @@ -6,10 +6,10 @@ defined-in-header: stlab/concurrency/future.hpp tags: - function overloads: - stlab::optional error(): + std::optional error(): description: In case an error occurred, it returns the stored exception pointer. return: __OPTIONAL__ - signature_with_names: "[[deprecated]] stlab::optional error() const" + signature_with_names: "[[deprecated]] std::optional error() const" --- Returns a potentially stored exception pointer. This function will be removed in future versions of the library. Use `exception()` instead. diff --git a/docs/libraries/concurrency/future/future/get_try.md b/docs/libraries/concurrency/future/future/get_try.md index 705ef12dd..affe34fdc 100644 --- a/docs/libraries/concurrency/future/future/get_try.md +++ b/docs/libraries/concurrency/future/future/get_try.md @@ -6,10 +6,10 @@ defined-in-header: stlab/concurrency/future.hpp tags: - function overloads: - stlab::optional get_try(): + std::optional get_try(): description: If `T` is not `void`, it returns an initialized `optional` if the future has succeeded, otherwise an empty `optional`. In case that an error occurred it rethrows the captured exception. return: __OPTIONAL__ - signature_with_names: stlab::optional get_try() + signature_with_names: std::optional get_try() bool get_try(): description: If `T` is void it returns `true` if the future succeeded, otherwise `false`. In case that an error occurred it rethrows the captured exception. return: __OPTIONAL__ diff --git a/docs/libraries/concurrency/optional.hpp/index.md b/docs/libraries/concurrency/optional.hpp/index.md deleted file mode 100644 index ef5ca8aca..000000000 --- a/docs/libraries/concurrency/optional.hpp/index.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -layout: library -title: concurrency/optional.hpp -owner: __MISSING__ -brief: __MISSING__ -tags: - - sourcefile -library-type: sourcefile -typedefs: - optional: - definition: std::optional - description: __MISSING__ ---- diff --git a/docs/libraries/concurrency/tuple_algorithm.hpp/index.md b/docs/libraries/concurrency/tuple_algorithm.hpp/index.md index 309fd2160..dd1bd621d 100644 --- a/docs/libraries/concurrency/tuple_algorithm.hpp/index.md +++ b/docs/libraries/concurrency/tuple_algorithm.hpp/index.md @@ -8,7 +8,7 @@ tags: library-type: sourcefile typedefs: optional_placeholder_tuple: - definition: std::tuple::value, detail::placeholder, Ts>::type>...> + definition: std::tuple::value, detail::placeholder, Ts>::type>...> description: __MISSING__ placeholder_tuple: definition: std::tuple::value, detail::placeholder, Ts>::type...> diff --git a/docs/libraries/concurrency/variant.hpp/f_get.md b/docs/libraries/concurrency/variant.hpp/f_get.md deleted file mode 100644 index 095614fe9..000000000 --- a/docs/libraries/concurrency/variant.hpp/f_get.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -layout: function -title: get -owner: __MISSING__ -brief: __MISSING__ -tags: - - function -defined_in_file: concurrency/variant.hpp -overloads: - "template \nconstexpr T & get(std::variant &)": - arguments: - - description: __OPTIONAL__ - name: v - type: std::variant & - description: __MISSING__ - return: __OPTIONAL__ - signature_with_names: "template \nconstexpr T & get(std::variant & v)" - "template \nconstexpr T && get(std::variant &&)": - arguments: - - description: __OPTIONAL__ - name: v - type: std::variant && - description: __MISSING__ - return: __OPTIONAL__ - signature_with_names: "template \nconstexpr T && get(std::variant && v)" - "template \nconstexpr const T & get(const std::variant &)": - arguments: - - description: __OPTIONAL__ - name: v - type: const std::variant & - description: __MISSING__ - return: __OPTIONAL__ - signature_with_names: "template \nconstexpr const T & get(const std::variant & v)" - "template \nconstexpr const T && get(const std::variant &&)": - arguments: - - description: __OPTIONAL__ - name: v - type: const std::variant && - description: __MISSING__ - return: __OPTIONAL__ - signature_with_names: "template \nconstexpr const T && get(const std::variant && v)" -namespace: - - stlab ---- diff --git a/docs/libraries/concurrency/variant.hpp/f_index.md b/docs/libraries/concurrency/variant.hpp/f_index.md deleted file mode 100644 index b649d68c5..000000000 --- a/docs/libraries/concurrency/variant.hpp/f_index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -layout: function -title: index -owner: __MISSING__ -brief: __MISSING__ -tags: - - function -defined_in_file: concurrency/variant.hpp -overloads: - "template \nconstexpr auto index(const std::variant &)": - arguments: - - description: __OPTIONAL__ - name: v - type: const std::variant & - description: __OPTIONAL__ - return: __OPTIONAL__ - signature_with_names: "template \nconstexpr auto index(const std::variant & v)" -namespace: - - stlab ---- diff --git a/docs/libraries/concurrency/variant.hpp/index.md b/docs/libraries/concurrency/variant.hpp/index.md deleted file mode 100644 index d47feb1fe..000000000 --- a/docs/libraries/concurrency/variant.hpp/index.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -layout: library -title: concurrency/variant.hpp -owner: __MISSING__ -brief: __MISSING__ -tags: - - sourcefile -library-type: sourcefile -typedefs: - variant: - definition: std::variant - description: __MISSING__ ---- diff --git a/stlab/CMakeLists.txt b/stlab/CMakeLists.txt index f9d97de57..1d1759b12 100644 --- a/stlab/CMakeLists.txt +++ b/stlab/CMakeLists.txt @@ -13,7 +13,6 @@ target_sources( stlab INTERFACE concurrency/future.hpp concurrency/immediate_executor.hpp concurrency/main_executor.hpp - concurrency/optional.hpp concurrency/progress.hpp concurrency/ready_future.hpp concurrency/serial_queue.hpp @@ -23,7 +22,6 @@ target_sources( stlab INTERFACE concurrency/traits.hpp concurrency/tuple_algorithm.hpp concurrency/utility.hpp - concurrency/variant.hpp iterator/set_next.hpp diff --git a/stlab/concurrency/await.hpp b/stlab/concurrency/await.hpp index 4d1881bcf..ceeb9b4be 100644 --- a/stlab/concurrency/await.hpp +++ b/stlab/concurrency/await.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -74,7 +75,7 @@ template struct _get_optional; template -struct _get_optional> { +struct _get_optional> { template auto operator()(F&& f) { return *std::forward(f); diff --git a/stlab/concurrency/channel.hpp b/stlab/concurrency/channel.hpp index 470b985dc..4d71fc715 100755 --- a/stlab/concurrency/channel.hpp +++ b/stlab/concurrency/channel.hpp @@ -18,14 +18,14 @@ #include #include #include +#include #include #include +#include #include -#include #include #include -#include #include #include @@ -191,19 +191,19 @@ using avoid = std::conditional_t::value, avoid_, T>; /**************************************************************************************************/ template -auto invoke_(F&& f, std::tuple...>& t, std::index_sequence) { +auto invoke_(F&& f, std::tuple...>& t, std::index_sequence) { return std::forward(f)(std::move(std::get(t))...); } template -auto avoid_invoke(F&& f, std::tuple...>& t) +auto avoid_invoke(F&& f, std::tuple...>& t) -> std::enable_if_t, Args...>>::value, yield_type, Args...>> { return invoke_(std::forward(f), t, std::make_index_sequence()); } template -auto avoid_invoke(F&& f, std::tuple...>& t) +auto avoid_invoke(F&& f, std::tuple...>& t) -> std::enable_if_t, Args...>>::value, avoid_> { invoke_(std::forward(f), t, std::make_index_sequence()); @@ -216,7 +216,7 @@ template struct invoke_variant_dispatcher { template static auto invoke_(F&& f, T& t, std::index_sequence) { - return std::forward(f)(std::move(stlab::get(std::get(t)))...); + return std::forward(f)(std::move(std::get(std::get(t)))...); } template @@ -228,25 +228,16 @@ struct invoke_variant_dispatcher { template <> struct invoke_variant_dispatcher<1> { - template - static auto invoke_(F&&, T&) -> std::enable_if_t::value, void> { - return; - } - template - static auto invoke_(F&& f, T&) -> std::enable_if_t::value, - decltype(std::forward(f)())> { - return std::forward(f)(); - } - template - static auto invoke_(F&& f, T& t) -> std::enable_if_t< - !(std::is_same::value || std::is_same::value), - decltype(std::forward(f)(std::move(stlab::get(std::get<0>(t)))))> { - return std::forward(f)(std::move(stlab::get(std::get<0>(t)))); - } - template - static auto invoke(F&& f, T& t) { - return invoke_>(std::forward(f), t); + static auto invoke(F&& f, [[maybe_unused]] T& t) { + using arg1_t = first_t; + if constexpr (std::is_same_v) { + return; + } else if constexpr (std::is_same_v) { + return std::forward(f)(); + } else { + return std::forward(f)(std::move(std::get(std::get<0>(t)))); + } } }; @@ -303,13 +294,13 @@ template constexpr bool has_process_close_v = is_detected_v; template -auto process_close(stlab::optional& x) +auto process_close(std::optional& x) -> std::enable_if_t>> { if (x) unwrap(*x).close(); } template -auto process_close(stlab::optional&) +auto process_close(std::optional&) -> std::enable_if_t>> {} /**************************************************************************************************/ @@ -321,13 +312,13 @@ template constexpr bool has_process_state_v = is_detected_v; template -auto get_process_state(const stlab::optional& x) +auto get_process_state(const std::optional& x) -> std::enable_if_t>, process_state_scheduled> { return unwrap(*x).state(); } template -auto get_process_state(const stlab::optional&) +auto get_process_state(const std::optional&) -> std::enable_if_t>, process_state_scheduled> { return await_forever; } @@ -371,30 +362,30 @@ constexpr bool has_process_await_v = is_detected_v; template void await_variant_args_(P& process, - std::tuple, std::exception_ptr>...>& args, + std::tuple, std::exception_ptr>...>& args, std::index_sequence) { - unwrap(process).await(std::move(stlab::get(std::get(args)))...); + unwrap(process).await(std::move(std::get(std::get(args)))...); } template void await_variant_args(P& process, - std::tuple, std::exception_ptr>...>& args) { + std::tuple, std::exception_ptr>...>& args) { await_variant_args_(process, args, std::make_index_sequence()); } /**************************************************************************************************/ template -stlab::optional find_argument_error(T& argument) { - stlab::optional result; +std::optional find_argument_error(T& argument) { + std::optional result; auto error_index = tuple_find(argument, [](const auto& c) { - return static_cast(index(c)) == message_t::error; + return static_cast(c.index()) == message_t::error; }); if (error_index != std::tuple_size::value) { result = get_i( - argument, error_index, [](auto& elem) { return stlab::get(elem); }, + argument, error_index, [](auto& elem) { return std::get(elem); }, std::exception_ptr{}); } @@ -406,9 +397,9 @@ stlab::optional find_argument_error(T& argument) { template struct default_queue_strategy { static const std::size_t arguments_size = 1; - using value_type = std::tuple, std::exception_ptr>>; + using value_type = std::tuple, std::exception_ptr>>; - std::deque, std::exception_ptr>> _queue; + std::deque, std::exception_ptr>> _queue; bool empty() const { return _queue.empty(); } @@ -435,9 +426,9 @@ template struct zip_with_queue_strategy { static const std::size_t Size = sizeof...(T); static const std::size_t arguments_size = Size; - using value_type = std::tuple...>; + using value_type = std::tuple...>; using queue_size_t = std::array; - using queue_t = std::tuple>...>; + using queue_t = std::tuple>...>; queue_t _queue; @@ -483,10 +474,10 @@ template struct round_robin_queue_strategy { static const std::size_t Size = sizeof...(T); static const std::size_t arguments_size = 1; - using item_t = variant, std::exception_ptr>; + using item_t = std::variant, std::exception_ptr>; using value_type = std::tuple; using queue_size_t = std::array; - using queue_t = std::tuple>...>; + using queue_t = std::tuple>...>; std::size_t _index{0}; std::size_t _popped_index{0}; queue_t _queue; @@ -539,10 +530,10 @@ template struct unordered_queue_strategy { static const std::size_t Size = sizeof...(T); static const std::size_t arguments_size = 1; - using item_t = variant, std::exception_ptr>; + using item_t = std::variant, std::exception_ptr>; using value_type = std::tuple; using queue_size_t = std::array; - using queue_t = std::tuple>...>; + using queue_t = std::tuple>...>; std::size_t _index{0}; std::size_t _popped_index{0}; queue_t _queue; @@ -696,14 +687,14 @@ template struct downstream< R, std::enable_if_t::value && !std::is_same::value>> { - stlab::optional> _data; + std::optional> _data; template void append_receiver(F&& f) { _data = std::forward(f); } - void clear() { _data = stlab::nullopt; } + void clear() { _data = std::nullopt; } std::size_t size() const { return 1; } @@ -746,7 +737,7 @@ struct shared_process queue_strategy_t _queue; executor_t _executor; - stlab::optional _process; + std::optional _process; std::mutex _process_mutex; @@ -830,7 +821,7 @@ struct shared_process if (do_final) { std::unique_lock lock(_downstream_mutex); _downstream.clear(); // This will propagate the close to anything downstream - _process = stlab::nullopt; + _process = std::nullopt; } } @@ -862,7 +853,7 @@ struct shared_process } auto pop_from_queue() { - stlab::optional message; + std::optional message; std::array do_cts = {{false}}; bool do_close = false; @@ -882,7 +873,7 @@ struct shared_process bool dequeue() { using queue_t = typename Q::value_type; - stlab::optional message; + std::optional message; std::array do_cts; bool do_close = false; @@ -1101,7 +1092,7 @@ struct shared_process template auto step() noexcept -> std::enable_if_t>> { using queue_t = typename Q::value_type; - stlab::optional message; + std::optional message; std::array do_cts; bool do_close = false; @@ -1119,8 +1110,6 @@ struct shared_process do_close = true; } else { try { - // The message cannot be moved because boost::variant supports r-values just - // since 1.65. broadcast( avoid_invoke_variant( std::move(*_process), *message)); @@ -1360,8 +1349,8 @@ struct buffer_size { namespace detail { struct annotations { - stlab::optional _executor; - stlab::optional _buffer_size; + std::optional _executor; + std::optional _buffer_size; annotations(executor_t e, std::size_t bs) : _executor(std::move(e)), _buffer_size(bs) {} explicit annotations(executor_t e) : _executor(std::move(e)) {} @@ -1618,8 +1607,8 @@ class sender> { if (p) p->send(std::forward(args)...); } - optional free_buffer() const { - optional result; + std::optional free_buffer() const { + std::optional result; auto p = _p.lock(); if (p) result = p->free_buffer(); return result; @@ -1676,8 +1665,8 @@ class sender> { if (p) p->send(std::forward(args)...); } - optional free_buffer() const { - optional result; + std::optional free_buffer() const { + std::optional result; auto p = _p.lock(); if (p) result = p->free_buffer(); return result; diff --git a/stlab/concurrency/future.hpp b/stlab/concurrency/future.hpp index ff814cd0a..f94c6741e 100755 --- a/stlab/concurrency/future.hpp +++ b/stlab/concurrency/future.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #ifndef STLAB_NO_STD_COROUTINES @@ -25,7 +26,6 @@ #include #include -#include #include #include #include @@ -259,7 +259,7 @@ struct shared_base> : std::enable_shared_from_this>>; executor_t _executor; - stlab::optional _result; + std::optional _result; std::exception_ptr _exception; std::mutex _mutex; std::atomic_bool _ready{false}; @@ -328,7 +328,7 @@ struct shared_base> : std::enable_shared_from_this stlab::optional { + auto get_try() -> std::optional { bool ready = false; { std::unique_lock lock(_mutex); @@ -338,10 +338,10 @@ struct shared_base> : std::enable_shared_from_this stlab::optional { + auto get_try_r(bool unique) -> std::optional { if (!unique) return get_try(); bool ready = false; @@ -353,7 +353,7 @@ struct shared_base> : std::enable_shared_from_this> : std::enable_shared_from_this< using then_t = std::pair>; executor_t _executor; - stlab::optional _result; + std::optional _result; std::exception_ptr _exception; std::mutex _mutex; std::atomic_bool _ready{false}; @@ -418,9 +418,9 @@ struct shared_base> : std::enable_shared_from_this< bool is_ready() const { return _ready; } - auto get_try() -> stlab::optional { return get_try_r(true); } + auto get_try() -> std::optional { return get_try_r(true); } - auto get_try_r(bool) -> stlab::optional { + auto get_try_r(bool) -> std::optional { bool ready = false; { std::unique_lock lock(_mutex); @@ -733,9 +733,9 @@ class STLAB_NODISCARD() future> { auto get_try() && { return _p->get_try_r(unique_usage(_p)); } - [[deprecated("Use exception() instead")]] stlab::optional error() const& { - return _p->_exception ? stlab::optional{_p->_exception} : - stlab::nullopt; + [[deprecated("Use exception() instead")]] std::optional error() const& { + return _p->_exception ? std::optional{_p->_exception} : + std::nullopt; } std::exception_ptr exception() const& { return _p->_exception; } @@ -881,9 +881,9 @@ class STLAB_NODISCARD() future { bool get_try() const& { return _p->get_try(); } - [[deprecated("Use exception() instead")]] stlab::optional error() const& { - return _p->_exception ? stlab::optional{_p->_exception} : - stlab::nullopt; + [[deprecated("Use exception() instead")]] std::optional error() const& { + return _p->_exception ? std::optional{_p->_exception} : + std::nullopt; } std::exception_ptr exception() const& { return _p->_exception; } @@ -986,9 +986,9 @@ class STLAB_NODISCARD() future> { auto get_try() && { return _p->get_try_r(unique_usage(_p)); } - [[deprecated("Use exception() instead")]] stlab::optional error() const& { - return _p->_exception ? stlab::optional{_p->_exception} : - stlab::nullopt; + [[deprecated("Use exception() instead")]] std::optional error() const& { + return _p->_exception ? std::optional{_p->_exception} : + std::nullopt; } std::exception_ptr exception() const& { return _p->_exception; } @@ -1076,7 +1076,7 @@ template struct when_any_shared { using result_type = R; // decay - stlab::optional _arg; + std::optional _arg; std::mutex _guard; future _holds[S]{}; std::size_t _remaining{S}; diff --git a/stlab/concurrency/optional.hpp b/stlab/concurrency/optional.hpp deleted file mode 100644 index bfa98c13d..000000000 --- a/stlab/concurrency/optional.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright 2015 Adobe - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -// The library can be used with boost::optional or std::optional. Usage of -// boost::optional is enabled when STLAB_USE_BOOST_CPP17_SHIMS is defined. - -/**************************************************************************************************/ - -#ifndef STLAB_CONCURRENCY_OPTIONAL_HPP -#define STLAB_CONCURRENCY_OPTIONAL_HPP - -#include - -/**************************************************************************************************/ - -#include - -#ifdef STLAB_USE_BOOST_CPP17_SHIMS - #include -#else - #include -#endif - -/**************************************************************************************************/ - -namespace stlab { - -/**************************************************************************************************/ - -#ifndef STLAB_USE_BOOST_CPP17_SHIMS - -template -using optional = std::optional; - -constexpr std::nullopt_t nullopt{std::nullopt}; - -/**************************************************************************************************/ - -#else - -template -using optional = boost::optional; - -const boost::none_t nullopt((boost::none_t::init_tag())); - -#endif - -/**************************************************************************************************/ - -} // namespace stlab - -/**************************************************************************************************/ - -#endif // STLAB_CONCURRENCY_OPTIONAL_HPP diff --git a/stlab/concurrency/tuple_algorithm.hpp b/stlab/concurrency/tuple_algorithm.hpp index d941c2fab..327d42f44 100644 --- a/stlab/concurrency/tuple_algorithm.hpp +++ b/stlab/concurrency/tuple_algorithm.hpp @@ -10,9 +10,8 @@ #ifndef STLAB_CONCURRENCY_TUPLE_ALGORITHM_HPP #define STLAB_CONCURRENCY_TUPLE_ALGORITHM_HPP -#include - // stdc++ +#include #include /**************************************************************************************************/ @@ -185,7 +184,7 @@ struct map_placeholder { }; template -struct map_placeholder, N> { +struct map_placeholder, N> { using type = std::index_sequence<>; }; @@ -225,7 +224,7 @@ using placeholder_tuple = std::tuple< // type-function that takes a parameter pack and returns a std::tuple // where all T[i] = void have been replaced with stlab::placeholder. template -using optional_placeholder_tuple = std::tuple::value, detail::placeholder, Ts>::type>...>; /**************************************************************************************************/ diff --git a/stlab/concurrency/variant.hpp b/stlab/concurrency/variant.hpp deleted file mode 100644 index 8d65be726..000000000 --- a/stlab/concurrency/variant.hpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright 2015 Adobe - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -*/ - -// The library can be used with boost::variant or std::variant. Usage of -// boost::variant is enabled when STLAB_USE_BOOST_CPP17_SHIMS is defined. - -/**************************************************************************************************/ - -#ifndef STLAB_CONCURRENCY_VARIANT_HPP -#define STLAB_CONCURRENCY_VARIANT_HPP - -/**************************************************************************************************/ - -#ifdef STLAB_USE_BOOST_CPP17_SHIMS - #include -#else - #include -#endif - -/**************************************************************************************************/ - -namespace stlab { - -/**************************************************************************************************/ - -#ifndef STLAB_USE_BOOST_CPP17_SHIMS - -template -using variant = std::variant; - -template -constexpr T& get(std::variant& v) { - return std::get(v); -} - -template -constexpr T&& get(std::variant&& v) { - return std::get(std::move(v)); -} - -template -constexpr const T& get(const std::variant& v) { - return std::get(v); -} - -template -constexpr const T&& get(const std::variant&& v) { - return std::get(std::move(v)); -} - -template -constexpr auto index(const std::variant& v) { - return v.index(); -} - -/**************************************************************************************************/ - -#else - -template -using variant = boost::variant; - -template -constexpr T& get(boost::variant& v) { - return boost::get(v); -} - -template -constexpr T& get(boost::variant& v) { - return boost::get(v); -} - -template -constexpr const T& get(const boost::variant& v) { - return boost::get(v); -} - -template -constexpr const T&& get(const boost::variant&& v) { - return boost::get(std::forward(v)); -} - -template -constexpr auto index(const boost::variant& v) { - return v.which(); -} - -#endif - -/**************************************************************************************************/ - -} // namespace stlab - -/**************************************************************************************************/ - -#endif // STLAB_CONCURRENCY_VARIANT_HPP diff --git a/stlab/config.hpp.in b/stlab/config.hpp.in index 953093ee4..5b4b85a3d 100644 --- a/stlab/config.hpp.in +++ b/stlab/config.hpp.in @@ -9,7 +9,6 @@ // Configuration generated from CMake -#cmakedefine STLAB_USE_BOOST_CPP17_SHIMS #cmakedefine STLAB_NO_STD_COROUTINES #define STLAB_THREADS(X) (STLAB_THREADS_##X()) diff --git a/stlab/forest_algorithms.hpp b/stlab/forest_algorithms.hpp index e463d5028..080676d6f 100644 --- a/stlab/forest_algorithms.hpp +++ b/stlab/forest_algorithms.hpp @@ -5,8 +5,10 @@ /**************************************************************************************************/ +// stdc++ +#include + // stlab -#include #include /**************************************************************************************************/ @@ -115,7 +117,7 @@ auto flatten(I first, I last, O out) { if (is_leading(first)) { *out++ = *first; } else { - *out++ = nullopt; + *out++ = std::nullopt; } } return out; @@ -123,7 +125,7 @@ auto flatten(I first, I last, O out) { /**************************************************************************************************/ -template +template class F> // F models Forest auto unflatten(I first, I last, F& f) { return forests::transcribe( diff --git a/test/forest_test.cpp b/test/forest_test.cpp index b3026842a..edc623b51 100644 --- a/test/forest_test.cpp +++ b/test/forest_test.cpp @@ -2,6 +2,7 @@ // stdc++ #include +#include // boost #include @@ -130,7 +131,7 @@ auto to_string(const std::string& x) { } template <> -auto to_string(const stlab::optional& x) { +auto to_string(const std::optional& x) { return x ? to_string(*x) : "?"; } @@ -463,7 +464,7 @@ BOOST_AUTO_TEST_CASE(test_transcribe_forest) { BOOST_AUTO_TEST_CASE(test_flatten) { auto f1{big_test_forest()}; - std::vector> flat; + std::vector> flat; forests::flatten(f1.begin(), f1.end(), std::back_inserter(flat));