diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-05-10 23:22:24 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-07-19 08:49:44 +0200 |
| commit | d37c3d175d74158b899f03d316bfe6ae96e89503 (patch) | |
| tree | 2d2d99fe25da057e8e9d6d68683c0a00a8118ae5 /src | |
| parent | 609bc24f67e53708d8cb93a070ab58d770e6e001 (diff) | |
More uses of standard type traits aliases
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.cc | 4 | ||||
| -rw-r--r-- | src/containers.hh | 21 | ||||
| -rw-r--r-- | src/hash.hh | 3 | ||||
| -rw-r--r-- | src/hash_map.hh | 6 | ||||
| -rw-r--r-- | 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<Completer, Rest...> : PerArgumentCommandCompl { template<typename C, typename... R, typename = typename std::enable_if<not std::is_base_of<PerArgumentCommandCompleter<>, - typename std::remove_reference<C>::type>::value>::type> + std::remove_reference_t<C>>::value>::type> PerArgumentCommandCompleter(C&& completer, R&&... rest) : PerArgumentCommandCompleter<Rest...>(std::forward<R>(rest)...), m_completer(std::forward<C>(completer)) {} @@ -93,7 +93,7 @@ struct PerArgumentCommandCompleter<Completer, Rest...> : PerArgumentCommandCompl }; template<typename... Completers> -PerArgumentCommandCompleter<typename std::decay<Completers>::type...> +PerArgumentCommandCompleter<std::decay_t<Completers>...> make_completer(Completers&&... completers) { return {std::forward<Completers>(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<typename C> -using RemoveReference = typename std::remove_reference<C>::type; - struct ReverseFactory { template<typename Container> - ReverseView<RemoveReference<Container>> operator()(Container&& container) const + ReverseView<std::remove_reference_t<Container>> operator()(Container&& container) const { return {std::move(container)}; } @@ -111,7 +108,7 @@ struct FilterFactory FilterView<Container&, Filter> operator()(Container& container) const { return {container, std::move(m_filter)}; } template<typename Container> - FilterView<RemoveReference<Container>, Filter> operator()(Container&& container) const { return {std::move(container), std::move(m_filter)}; } + FilterView<std::remove_reference_t<Container>, Filter> operator()(Container&& container) const { return {std::move(container), std::move(m_filter)}; } Filter m_filter; }; @@ -165,7 +162,7 @@ struct TransformFactory TransformView<Container&, Transform> operator()(Container& container) const { return {container, std::move(m_transform)}; } template<typename Container> - TransformView<RemoveReference<Container>, Transform> operator()(Container&& container) const { return {std::move(container), std::move(m_transform)}; } + TransformView<std::remove_reference_t<Container>, Transform> operator()(Container&& container) const { return {std::move(container), std::move(m_transform)}; } Transform m_transform; }; @@ -178,9 +175,9 @@ template<typename Container, typename Separator = ValueOf<Container>, struct SplitView { using ContainerIt = IteratorOf<Container>; - using ValueType = typename std::conditional<std::is_same<void, ValueTypeParam>::value, - std::pair<IteratorOf<Container>, IteratorOf<Container>>, - ValueTypeParam>::type; + using ValueType = std::conditional_t<std::is_same<void, ValueTypeParam>::value, + std::pair<IteratorOf<Container>, IteratorOf<Container>>, + ValueTypeParam>; struct Iterator : std::iterator<std::forward_iterator_tag, ValueType> { @@ -233,7 +230,7 @@ template<typename ValueType, typename Separator> struct SplitViewFactory { template<typename Container> - SplitView<RemoveReference<Container>, Separator, ValueType> + SplitView<std::remove_reference_t<Container>, Separator, ValueType> operator()(Container&& container) const { return {std::move(container), std::move(separator)}; } template<typename Container> @@ -251,8 +248,8 @@ struct ConcatView { using ContainerIt1 = decltype(begin(std::declval<Container1>())); using ContainerIt2 = decltype(begin(std::declval<Container2>())); - using ValueType = typename std::common_type<typename std::iterator_traits<ContainerIt1>::value_type, - typename std::iterator_traits<ContainerIt2>::value_type>::type; + using ValueType = typename std::common_type_t<typename std::iterator_traits<ContainerIt1>::value_type, + typename std::iterator_traits<ContainerIt2>::value_type>; struct Iterator : std::iterator<std::forward_iterator_tag, ValueType> { 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<typename T> struct HashCompatible<T, T> : std::true_type {}; +template<typename Lhs, typename Rhs> +constexpr bool IsHashCompatible = HashCompatible<Lhs, Rhs>::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<typename KeyType> - using EnableIfHashCompatible = typename std::enable_if< - HashCompatible<Key, typename std::decay<KeyType>::type>::value - >::type; + using EnableIfHashCompatible = std::enable_if_t< + IsHashCompatible<Key, std::decay_t<KeyType>> + >; template<typename KeyType, typename = EnableIfHashCompatible<KeyType>> 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<T>) } template<typename Enum> -typename std::enable_if<std::is_enum<Enum>::value, String>::type +std::enable_if_t<std::is_enum<Enum>::value, String> option_type_name(Meta::Type<Enum>) { return format("{}({})", with_bit_ops(Meta::Type<Enum>{}) ? "flags" : "enum", |
