Skip to content
Snippets Groups Projects
Commit d7aaa141 authored by Benedikt Steinbusch's avatar Benedikt Steinbusch
Browse files

replace boost::variant by std::variant

parent 2d74cab8
No related branches found
No related tags found
No related merge requests found
Pipeline #59258 passed
......@@ -9,6 +9,7 @@
### Changed
- `boost::variant` has been replaced by `std::variant` and Boost is no longer needed as a dependency
- If no explicit choice is made via `CMAKE_POSITION_INDEPENDENT_CODE`, the client library defaults to being built as position independent code
[Unreleased]: https://gitlab.version.fz-juelich.de/SIONlib/SIONfwd/-/compare/v1.0.0...main
......@@ -18,7 +18,6 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_C_EXTENSIONS FALSE)
find_package(Boost 1.69 REQUIRED)
find_package(MPI 3.0 REQUIRED)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable")
......@@ -49,7 +48,6 @@ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
endif()
add_executable(sionfwd-server src/server.cxx)
target_link_libraries(sionfwd-server PRIVATE Boost::boost)
target_link_libraries(sionfwd-server PRIVATE MPI::MPI_CXX)
add_executable(sionfwd-test-client src/test-client.c)
......
......@@ -9,7 +9,6 @@ It contains a C++ server and a C client library.
- C++ compiler with support for C++17
- CMake 3.12 or newer
- MPI 3.0 or newer
- Boost 1.69 or newer
## Installation
......
include(CMakeFindDependencyMacro)
find_dependency(MPI 3.0)
find_dependency(Boost 1.69)
include("${CMAKE_CURRENT_LIST_DIR}/SIONfwdTargets.cmake")
......@@ -11,10 +11,9 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <variant>
#include <vector>
#include <boost/variant.hpp>
#include <mpi.h>
static bool debug = false;
......@@ -214,7 +213,7 @@ private:
struct Unknown {};
using Message = boost::variant<
using Message = std::variant<
Shutdown,
Hello,
Disconnect,
......@@ -228,11 +227,6 @@ using Message = boost::variant<
Unknown
>;
template<typename T, typename... Us>
bool holds_alternative(const boost::variant<Us...>& v) {
return boost::get<T>(&v) != nullptr;
}
struct Communicator {
explicit Communicator(MPI_Comm comm) noexcept : comm_{comm} {}
......@@ -460,7 +454,7 @@ struct CommunicatorReceiver {
bool go_on;
do {
Message message{communicator_.receive()};
go_on = boost::apply_visitor(MessageVisitor{communicator_}, std::move(message));
go_on = std::visit(MessageVisitor{communicator_}, std::move(message));
} while (go_on);
}
......@@ -521,8 +515,8 @@ struct PortAcceptor {
}
Communicator client{port_.accept()};
Message message{client.receive()};
if (holds_alternative<Shutdown>(message)) { break; }
if (!holds_alternative<Hello>(message)) {
if (std::holds_alternative<Shutdown>(message)) { break; }
if (!std::holds_alternative<Hello>(message)) {
throw std::runtime_error{"unexpected message type"};
}
CommunicatorReceiver{std::move(client)}();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment