Skip to content

Commit

Permalink
cmake|Plugin|Expected|test: Fix C++17 compilation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
taminob committed Mar 14, 2024
1 parent 1eed902 commit b6b2d86
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ if(${PPPLUGIN_ENABLE_CPP17_COMPATIBILITY})
set(CMAKE_CXX_STANDARD 17)
# TODO: generate C++17 compatible header files instead
add_definitions("-DPPPLUGIN_CPP17_COMPATIBILITY")
target_link_libraries(${LIBRARY_TARGET_SHARED} fmt::fmt)
target_link_libraries(${LIBRARY_TARGET_STATIC} fmt::fmt)
else()
set(CMAKE_CXX_STANDARD 20)
endif()
Expand Down
11 changes: 9 additions & 2 deletions include/expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ class Expected {
template <typename U, typename V,
typename = std::enable_if_t<std::is_convertible_v<U, T> && std::is_convertible_v<V, E>>>
constexpr Expected(const Expected<U, V>& rhs);
template <typename U, typename V,
typename = std::enable_if_t<std::is_nothrow_convertible_v<U, T> && std::is_nothrow_convertible_v<V, E>>>
template <typename U, typename V
#ifdef PPPLUGIN_CPP17_COMPATIBILITY
,
typename = std::enable_if_t<std::is_convertible_v<U, T> && std::is_convertible_v<V, E>>
#else
,
typename = std::enable_if_t<std::is_nothrow_convertible_v<U, T> && std::is_nothrow_convertible_v<V, E>>
#endif // PPPLUGIN_CPP17_COMPATIBILITY
>
constexpr Expected(Expected<U, V>&& rhs) noexcept;
constexpr Expected& operator=(const Expected&) = default;
constexpr Expected& operator=(Expected&&) noexcept = default;
Expand Down
6 changes: 3 additions & 3 deletions include/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class GenericPlugin {

GenericPlugin() = default;
template <typename P,
std::enable_if_t<(std::is_base_of_v<Plugins, std::remove_cvref_t<P>> || ...), bool> = true>
std::enable_if_t<(std::is_base_of_v<Plugins, std::remove_cv_t<std::remove_reference_t<P>>> || ...), bool> = true>
GenericPlugin(P&& plugin); // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)

virtual ~GenericPlugin() = default;
~GenericPlugin() = default;
GenericPlugin(const GenericPlugin&) = default;
GenericPlugin(GenericPlugin&&) noexcept = default;
GenericPlugin& operator=(const GenericPlugin&) = default;
Expand All @@ -68,7 +68,7 @@ using Plugin = GenericPlugin<CPlugin, CppPlugin, LuaPlugin, PythonPlugin, NoopPl

template <typename... Plugins>
template <typename P,
std::enable_if_t<(std::is_base_of_v<Plugins, std::remove_cvref_t<P>> || ...), bool>>
std::enable_if_t<(std::is_base_of_v<Plugins, std::remove_cv_t<std::remove_reference_t<P>>> || ...), bool>>
// NOLINTNEXTLINE(bugprone-forwarding-reference-overload); enable_if condition prevents hiding copy/move ctors
GenericPlugin<Plugins...>::GenericPlugin(P&& plugin)
: plugin_(std::forward<P>(plugin))
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ target_link_libraries(
PUBLIC Boost::python
PUBLIC Python::Python
PRIVATE ${LUA_LIBRARIES})
if(${PPPLUGIN_ENABLE_CPP17_COMPATIBILITY})
target_link_libraries(${LIBRARY_TARGET} PUBLIC fmt::fmt)
endif()
target_include_directories(
${LIBRARY_TARGET}
PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
Expand Down
2 changes: 1 addition & 1 deletion test/expected_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "expected.h"
#include "test/test_types.h"
#include "test_types.h"
#include "test_helper.h"

#include <gmock/gmock.h>
Expand Down

0 comments on commit b6b2d86

Please sign in to comment.