From d37c3d175d74158b899f03d316bfe6ae96e89503 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 10 May 2017 23:22:24 +0100 Subject: [PATCH] More uses of standard type traits aliases --- src/commands.cc | 4 ++-- src/containers.hh | 21 +++++++++------------ src/hash.hh | 3 +++ src/hash_map.hh | 6 +++--- src/option_types.hh | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 199e768a..ce54da90 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -69,7 +69,7 @@ struct PerArgumentCommandCompleter : PerArgumentCommandCompl { template, - typename std::remove_reference::type>::value>::type> + std::remove_reference_t>::value>::type> PerArgumentCommandCompleter(C&& completer, R&&... rest) : PerArgumentCommandCompleter(std::forward(rest)...), m_completer(std::forward(completer)) {} @@ -93,7 +93,7 @@ struct PerArgumentCommandCompleter : PerArgumentCommandCompl }; template -PerArgumentCommandCompleter::type...> +PerArgumentCommandCompleter...> make_completer(Completers&&... completers) { return {std::forward(completers)...}; diff --git a/src/containers.hh b/src/containers.hh index d49a1d65..b51e8092 100644 --- a/src/containers.hh +++ b/src/containers.hh @@ -29,13 +29,10 @@ struct ReverseView Container m_container; }; -template -using RemoveReference = typename std::remove_reference::type; - struct ReverseFactory { template - ReverseView> operator()(Container&& container) const + ReverseView> operator()(Container&& container) const { return {std::move(container)}; } @@ -111,7 +108,7 @@ struct FilterFactory FilterView operator()(Container& container) const { return {container, std::move(m_filter)}; } template - FilterView, Filter> operator()(Container&& container) const { return {std::move(container), std::move(m_filter)}; } + FilterView, Filter> operator()(Container&& container) const { return {std::move(container), std::move(m_filter)}; } Filter m_filter; }; @@ -165,7 +162,7 @@ struct TransformFactory TransformView operator()(Container& container) const { return {container, std::move(m_transform)}; } template - TransformView, Transform> operator()(Container&& container) const { return {std::move(container), std::move(m_transform)}; } + TransformView, Transform> operator()(Container&& container) const { return {std::move(container), std::move(m_transform)}; } Transform m_transform; }; @@ -178,9 +175,9 @@ template, struct SplitView { using ContainerIt = IteratorOf; - using ValueType = typename std::conditional::value, - std::pair, IteratorOf>, - ValueTypeParam>::type; + using ValueType = std::conditional_t::value, + std::pair, IteratorOf>, + ValueTypeParam>; struct Iterator : std::iterator { @@ -233,7 +230,7 @@ template struct SplitViewFactory { template - SplitView, Separator, ValueType> + SplitView, Separator, ValueType> operator()(Container&& container) const { return {std::move(container), std::move(separator)}; } template @@ -251,8 +248,8 @@ struct ConcatView { using ContainerIt1 = decltype(begin(std::declval())); using ContainerIt2 = decltype(begin(std::declval())); - using ValueType = typename std::common_type::value_type, - typename std::iterator_traits::value_type>::type; + using ValueType = typename std::common_type_t::value_type, + typename std::iterator_traits::value_type>; struct Iterator : std::iterator { diff --git a/src/hash.hh b/src/hash.hh index a79bbf3c..35e89e84 100644 --- a/src/hash.hh +++ b/src/hash.hh @@ -65,6 +65,9 @@ struct HashCompatible : std::false_type {}; template struct HashCompatible : std::true_type {}; +template +constexpr bool IsHashCompatible = HashCompatible::value; + } #endif // hash_hh_INCLUDED diff --git a/src/hash_map.hh b/src/hash_map.hh index 1336c94a..4263b195 100644 --- a/src/hash_map.hh +++ b/src/hash_map.hh @@ -155,9 +155,9 @@ struct HashMap } template - using EnableIfHashCompatible = typename std::enable_if< - HashCompatible::type>::value - >::type; + using EnableIfHashCompatible = std::enable_if_t< + IsHashCompatible> + >; template> int find_index(const KeyType& key, size_t hash) const diff --git a/src/option_types.hh b/src/option_types.hh index 53b10ab6..1c44ddce 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -24,7 +24,7 @@ constexpr decltype(T::option_type_name) option_type_name(Meta::Type) } template -typename std::enable_if::value, String>::type +std::enable_if_t::value, String> option_type_name(Meta::Type) { return format("{}({})", with_bit_ops(Meta::Type{}) ? "flags" : "enum",