From 22d630fec125c44a60878dcd664b32b65403efae Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Mon, 20 Jan 2020 12:18:05 +0900 Subject: [PATCH] feat: replace detail::stuff by std if possible --- toml/traits.hpp | 28 ++++++++++++++++++++++++++++ toml/utility.hpp | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/toml/traits.hpp b/toml/traits.hpp index ec05f08..4fc1bda 100644 --- a/toml/traits.hpp +++ b/toml/traits.hpp @@ -111,6 +111,14 @@ struct has_into_toml_method // --------------------------------------------------------------------------- // C++17 and/or/not +#if __cplusplus >= 201703L + +using std::conjunction; +using std::disjunction; +using std::negation; + +#else + template struct conjunction : std::true_type{}; template struct conjunction : T{}; template @@ -128,6 +136,8 @@ struct disjunction : template struct negation : std::integral_constant(T::value)>{}; +#endif + // --------------------------------------------------------------------------- // type checkers @@ -182,6 +192,13 @@ struct is_basic_value<::toml::basic_value>: std::true_type{}; // --------------------------------------------------------------------------- // C++14 index_sequence +#if __cplusplus >= 201402L + +using std::index_sequence; +using std::make_index_sequence; + +#else + template struct index_sequence{}; template struct push_back_index_sequence{}; @@ -205,11 +222,22 @@ struct index_sequence_maker<0> template using make_index_sequence = typename index_sequence_maker::type; +#endif // __cplusplus >= 2014 + // --------------------------------------------------------------------------- // C++14 enable_if_t + +#if __cplusplus >= 201402L + +using std::enable_if_t; + +#else + template using enable_if_t = typename std::enable_if::type; +#endif // __cplusplus >= 2014 + // --------------------------------------------------------------------------- // return_type_of_t diff --git a/toml/utility.hpp b/toml/utility.hpp index 73ae26e..bac1249 100644 --- a/toml/utility.hpp +++ b/toml/utility.hpp @@ -20,12 +20,20 @@ namespace toml { +#if __cplusplus >= 201402L + +using std::make_unique; + +#else + template inline std::unique_ptr make_unique(Ts&& ... args) { return std::unique_ptr(new T(std::forward(args)...)); } +#endif // __cplusplus >= 2014 + namespace detail {