Skip to content

Commit

Permalink
Enable c++-17
Browse files Browse the repository at this point in the history
  • Loading branch information
seelabs committed Aug 5, 2019
1 parent e1adbd7 commit f94b660
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 79 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,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
$<$<CONFIG:Debug>:DEBUG _DEBUG>
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/basics/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace detail {
// Determines if a type can be called like an Engine
template <class Engine, class Result = typename Engine::result_type>
using is_engine =
std::is_invocable<Engine, Result()>;
std::is_invocable_r<Result, Engine>;
}

/** Return the default random engine.
Expand Down
78 changes: 7 additions & 71 deletions src/ripple/beast/cxx17/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,82 +24,18 @@
#include <type_traits>
#include <utility>

namespace std {

#ifndef _MSC_VER

#if ! __cpp_lib_void_t

template<class...>
using void_t = void;

#endif // ! __cpp_lib_void_t

#if ! __cpp_lib_bool_constant

template<bool B>
using bool_constant = std::integral_constant<bool, B>;

#endif // ! __cpp_lib_bool_constant

#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 <class T, class U>
struct is_constructible <pair <T, U>>
: integral_constant <bool,
is_default_constructible <T>::value &&
is_default_constructible <U>::value>
{
explicit is_constructible() = default;
};
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 6000

//------------------------------------------------------------------------------

namespace detail {
template<class R, class C, class ...A>
auto
is_invocable_test(C&& c, int, A&& ...a)
-> decltype(std::is_convertible<
decltype(c(std::forward<A>(a)...)), R>::value ||
std::is_same<R, void>::value,
std::true_type());

template<class R, class C, class ...A>
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<T, void(std::string)>
@endcode
*/
/** @{ */
template<class C, class F>
struct is_invocable : std::false_type
{
};
namespace std {

template<class C, class R, class ...A>
struct is_invocable<C, R(A...)>
: decltype(std::detail::is_invocable_test<R>(
std::declval<C>(), 1, std::declval<A>()...))
template <class _Ret, class _Fn, class... _Args>
struct _LIBCPP_TEMPLATE_VIS is_invocable_r
: integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value>
{
};
/** @} */

//------------------------------------------------------------------------------
} // namespace std

} // std
#endif

#endif
8 changes: 2 additions & 6 deletions src/test/jtx/Env.h
Original file line number Diff line number Diff line change
Expand Up @@ -673,19 +673,15 @@ class Env
void
invoke (STTx& stx, FN const&... fN)
{
// Sean Parent for_each_argument trick (C++ fold expressions would be
// nice here)
(void)std::array<int, sizeof...(fN)>{{((fN(*this, stx)), 0)...}};
(fN(*this, stx),...);
}

// Invoke funclets on jt
template <class... FN>
void
invoke (JTx& jt, FN const&... fN)
{
// Sean Parent for_each_argument trick (C++ fold expressions would be
// nice here)
(void)std::array<int, sizeof...(fN)>{{((fN(*this, jt)), 0)...}};
(fN(*this, jt),...);
}

// Map of account IDs to Account
Expand Down

0 comments on commit f94b660

Please sign in to comment.