Skip to content

Commit

Permalink
Removing use of boost::variant and optional from stlab now that it ha…
Browse files Browse the repository at this point in the history
…s moved to C++17 (#531)

* Removing use of boost::variant and optional from stlab now that it has moved to C++17

* fixing one Windows error

* adding using type for clarity

* Update docs/tips/stop-using-out-arguments.md

---------

Co-authored-by: Bryn Aspestrand <[email protected]>
  • Loading branch information
thinlang and Bryn Aspestrand authored Oct 25, 2023
1 parent 4044ffa commit 12fc5a5
Show file tree
Hide file tree
Showing 24 changed files with 90 additions and 387 deletions.
11 changes: 0 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -89,10 +83,6 @@ target_compile_definitions( stlab INTERFACE $<$<CXX_COMPILER_ID:MSVC>: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()
Expand All @@ -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}")
Expand Down
24 changes: 0 additions & 24 deletions cmake/StlabUtil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 <variant>
#include <optional>
int main() {
std::optional<int> op = 3;
op = std::nullopt;
std::variant<int, char> 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
Expand Down
4 changes: 0 additions & 4 deletions cmake/stlabConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ tags:
- method
defined_in_file: concurrency/future.hpp
overloads:
stlab::optional<std::exception_ptr> error() const &:
std::optional<std::exception_ptr> error() const &:
annotation:
- deprecated (Use exception() instead)
description: __OPTIONAL__
return: __OPTIONAL__
signature_with_names: stlab::optional<std::exception_ptr> error() const &
signature_with_names: std::optional<std::exception_ptr> error() const &
---
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ tags:
- method
defined_in_file: concurrency/future.hpp
overloads:
stlab::optional<std::exception_ptr> error() const &:
std::optional<std::exception_ptr> error() const &:
annotation:
- deprecated (Use exception() instead)
description: Iff an error occurred, returns the stored exception pointer.
return: __OPTIONAL__
signature_with_names: stlab::optional<std::exception_ptr> error() const &
signature_with_names: std::optional<std::exception_ptr> error() const &
---
Returns a potentially stored exception pointer. This function will be removed in future versions of the library. Use `exception()` instead.

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ tags:
- method
defined_in_file: concurrency/future.hpp
overloads:
stlab::optional<std::exception_ptr> error() const &:
std::optional<std::exception_ptr> error() const &:
annotation:
- deprecated (Use exception() instead)
description: __OPTIONAL__
return: __OPTIONAL__
signature_with_names: stlab::optional<std::exception_ptr> error() const &
signature_with_names: std::optional<std::exception_ptr> error() const &
---
4 changes: 2 additions & 2 deletions docs/libraries/concurrency/future/future/error.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ defined-in-header: stlab/concurrency/future.hpp
tags:
- function
overloads:
stlab::optional<std::exception_ptr> error():
std::optional<std::exception_ptr> error():
description: In case an error occurred, it returns the stored exception pointer.
return: __OPTIONAL__
signature_with_names: "[[deprecated]] stlab::optional<std::exception_ptr> error() const"
signature_with_names: "[[deprecated]] std::optional<std::exception_ptr> error() const"
---
Returns a potentially stored exception pointer. This function will be removed in future versions of the library. Use `exception()` instead.

4 changes: 2 additions & 2 deletions docs/libraries/concurrency/future/future/get_try.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ defined-in-header: stlab/concurrency/future.hpp
tags:
- function
overloads:
stlab::optional<T> get_try():
std::optional<T> get_try():
description: If `T` is not `void`, it returns an initialized `optional` if the future has succeeded, otherwise an empty `optional<T>`. In case that an error occurred it rethrows the captured exception.
return: __OPTIONAL__
signature_with_names: stlab::optional<T> get_try()
signature_with_names: std::optional<T> 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__
Expand Down
13 changes: 0 additions & 13 deletions docs/libraries/concurrency/optional.hpp/index.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/libraries/concurrency/tuple_algorithm.hpp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tags:
library-type: sourcefile
typedefs:
optional_placeholder_tuple:
definition: std::tuple<stlab::optional<typename std::conditional<std::is_same<void, Ts>::value, detail::placeholder, Ts>::type>...>
definition: std::tuple<std::optional<typename std::conditional<std::is_same<void, Ts>::value, detail::placeholder, Ts>::type>...>
description: __MISSING__
placeholder_tuple:
definition: std::tuple<typename std::conditional<std::is_same<void, Ts>::value, detail::placeholder, Ts>::type...>
Expand Down
44 changes: 0 additions & 44 deletions docs/libraries/concurrency/variant.hpp/f_get.md

This file was deleted.

20 changes: 0 additions & 20 deletions docs/libraries/concurrency/variant.hpp/f_index.md

This file was deleted.

13 changes: 0 additions & 13 deletions docs/libraries/concurrency/variant.hpp/index.md

This file was deleted.

2 changes: 0 additions & 2 deletions stlab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion stlab/concurrency/await.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <condition_variable>
#include <exception>
#include <mutex>
#include <optional>
#include <type_traits>
#include <utility>

Expand Down Expand Up @@ -74,7 +75,7 @@ template <class T>
struct _get_optional;

template <class T>
struct _get_optional<stlab::optional<T>> {
struct _get_optional<std::optional<T>> {
template <class F>
auto operator()(F&& f) {
return *std::forward<F>(f);
Expand Down
Loading

0 comments on commit 12fc5a5

Please sign in to comment.