More uses of standard type traits aliases

This commit is contained in:
Maxime Coste 2017-05-10 23:22:24 +01:00
parent 609bc24f67
commit d37c3d175d
5 changed files with 18 additions and 18 deletions

View File

@ -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)...};

View File

@ -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>
{

View File

@ -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

View File

@ -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

View File

@ -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",