From c217baa367a65724808c5df9d157b9a22eb6f563 Mon Sep 17 00:00:00 2001 From: seelabs Date: Fri, 22 Mar 2019 09:19:35 -0400 Subject: [PATCH] Enable C++17 --- CMakeLists.txt | 3 +- src/ripple/basics/date.h | 1 + src/ripple/basics/random.h | 2 +- src/ripple/beast/cxx17/type_traits.h | 80 +++------------------------- src/test/jtx/Env.h | 8 +-- 5 files changed, 14 insertions(+), 80 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9913d453be..a44435d36b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -478,7 +478,8 @@ add_library (Ripple::common ALIAS common) link_libraries (Ripple::common) set_target_properties (common PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON) -target_compile_features (common INTERFACE cxx_std_14) +set(CMAKE_CXX_EXTENSIONS OFF) +target_compile_features (common INTERFACE cxx_std_17) target_compile_definitions (common INTERFACE $<$:DEBUG _DEBUG> diff --git a/src/ripple/basics/date.h b/src/ripple/basics/date.h index 537806cbb0..f769bb9ae6 100644 --- a/src/ripple/basics/date.h +++ b/src/ripple/basics/date.h @@ -30,6 +30,7 @@ // been invented (that would involve another several millennia of evolution). // We did not mean to shout. +#define HAS_STRING_VIEW 0 #ifndef HAS_STRING_VIEW # if __cplusplus >= 201703 # define HAS_STRING_VIEW 1 diff --git a/src/ripple/basics/random.h b/src/ripple/basics/random.h index 82dd873b56..e075222960 100644 --- a/src/ripple/basics/random.h +++ b/src/ripple/basics/random.h @@ -51,7 +51,7 @@ namespace detail { // Determines if a type can be called like an Engine template using is_engine = - std::is_invocable; + std::is_invocable_r; } /** Return the default random engine. diff --git a/src/ripple/beast/cxx17/type_traits.h b/src/ripple/beast/cxx17/type_traits.h index 95f42b1050..0dfeee45bd 100644 --- a/src/ripple/beast/cxx17/type_traits.h +++ b/src/ripple/beast/cxx17/type_traits.h @@ -24,82 +24,18 @@ #include #include +#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 6000 + namespace std { -#ifndef _MSC_VER +template +struct _LIBCPP_TEMPLATE_VIS is_invocable_r + : integral_constant::value> +{ +}; - #if ! __cpp_lib_void_t - - template - using void_t = void; - - #endif // ! __cpp_lib_void_t - - #if ! __cpp_lib_bool_constant - - template - using bool_constant = std::integral_constant; - - #endif // ! __cpp_lib_bool_constant +} // namespace std #endif -// Ideas from Howard Hinnant -// -// Specializations of is_constructible for pair and tuple which -// work around an apparent defect in the standard that causes well -// formed expressions involving pairs or tuples of non default-constructible -// types to generate compile errors. -// -template -struct is_constructible > - : integral_constant ::value && - is_default_constructible ::value> -{ - explicit is_constructible() = default; -}; - -//------------------------------------------------------------------------------ - -namespace detail { -template -auto -is_invocable_test(C&& c, int, A&& ...a) - -> decltype(std::is_convertible< - decltype(c(std::forward(a)...)), R>::value || - std::is_same::value, - std::true_type()); - -template -std::false_type -is_invocable_test(C&& c, long, A&& ...a); -} // detail - -/** Metafunction returns `true` if F callable as R(A...) - - Example: - - @code - is_invocable - @endcode -*/ -/** @{ */ -template -struct is_invocable : std::false_type -{ -}; - -template -struct is_invocable - : decltype(std::detail::is_invocable_test( - std::declval(), 1, std::declval()...)) -{ -}; -/** @} */ - -//------------------------------------------------------------------------------ - -} // std - #endif diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index 9fe44862f9..d72f00f543 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -673,9 +673,7 @@ protected: void invoke (STTx& stx, FN const&... fN) { - // Sean Parent for_each_argument trick (C++ fold expressions would be - // nice here) - (void)std::array{{((fN(*this, stx)), 0)...}}; + (fN(*this, stx),...); } // Invoke funclets on jt @@ -683,9 +681,7 @@ protected: void invoke (JTx& jt, FN const&... fN) { - // Sean Parent for_each_argument trick (C++ fold expressions would be - // nice here) - (void)std::array{{((fN(*this, jt)), 0)...}}; + (fN(*this, jt),...); } // Map of account IDs to Account