mirror of
https://github.com/Naios/continuable.git
synced 2026-01-01 03:12:12 +08:00
Move from std::decay to std::decay_t
* Makes the transition to traits::unref easier later
This commit is contained in:
parent
a9d4ee5ba8
commit
646707e5dc
@ -97,10 +97,8 @@ public:
|
||||
/// given iterator tuple.
|
||||
template <typename Frame, typename State>
|
||||
auto make_resume_traversal_callable(Frame&& frame, State&& state)
|
||||
-> resume_traversal_callable<typename std::decay<Frame>::type,
|
||||
typename std::decay<State>::type> {
|
||||
return resume_traversal_callable<typename std::decay<Frame>::type,
|
||||
typename std::decay<State>::type>(
|
||||
-> resume_traversal_callable<std::decay_t<Frame>, std::decay_t<State>> {
|
||||
return resume_traversal_callable<std::decay_t<Frame>, std::decay_t<State>>(
|
||||
std::forward<Frame>(frame), std::forward<State>(state));
|
||||
}
|
||||
|
||||
@ -291,9 +289,9 @@ struct dynamic_async_range {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using dynamic_async_range_of_t = dynamic_async_range<
|
||||
typename std::decay<decltype(std::begin(std::declval<T>()))>::type,
|
||||
typename std::decay<decltype(std::end(std::declval<T>()))>::type>;
|
||||
using dynamic_async_range_of_t =
|
||||
dynamic_async_range<std::decay_t<decltype(std::begin(std::declval<T>()))>,
|
||||
std::decay_t<decltype(std::end(std::declval<T>()))>>;
|
||||
|
||||
/// Returns a dynamic range for the given type
|
||||
template <typename T>
|
||||
@ -337,9 +335,8 @@ public:
|
||||
auto hierarchy = std::tuple_cat(
|
||||
std::make_tuple(std::forward<Parent>(parent)), hierarchy_);
|
||||
|
||||
return async_traversal_point<Frame, typename std::decay<Parent>::type,
|
||||
Hierarchy...>(frame_, std::move(hierarchy),
|
||||
detached_);
|
||||
return async_traversal_point<Frame, std::decay_t<Parent>, Hierarchy...>(
|
||||
frame_, std::move(hierarchy), detached_);
|
||||
}
|
||||
|
||||
/// Forks the current traversal point and continues the child
|
||||
@ -405,7 +402,7 @@ public:
|
||||
/// Async traverse the current iterator
|
||||
template <typename Current>
|
||||
void async_traverse_one(Current&& current) {
|
||||
using ElementType = typename std::decay<decltype(*current)>::type;
|
||||
using ElementType = std::decay_t<decltype(*current)>;
|
||||
return async_traverse_one_impl(container_category_of_t<ElementType>{},
|
||||
std::forward<Current>(current));
|
||||
}
|
||||
@ -453,8 +450,7 @@ public:
|
||||
/// given frame and hierarchy
|
||||
template <typename Frame, typename... Hierarchy>
|
||||
using traversal_point_of_t =
|
||||
async_traversal_point<typename std::decay<Frame>::type,
|
||||
typename std::decay<Hierarchy>::type...>;
|
||||
async_traversal_point<std::decay_t<Frame>, std::decay_t<Hierarchy>...>;
|
||||
|
||||
/// A callable object which is capable of resuming an asynchronous
|
||||
/// pack traversal.
|
||||
@ -528,8 +524,8 @@ template <typename Visitor, typename... Args>
|
||||
struct async_traversal_types {
|
||||
/// Deduces to the async traversal frame type of the given
|
||||
/// traversal arguments and mapper
|
||||
using frame_t = async_traversal_frame<typename std::decay<Visitor>::type,
|
||||
typename std::decay<Args>::type...>;
|
||||
using frame_t =
|
||||
async_traversal_frame<std::decay_t<Visitor>, std::decay_t<Args>...>;
|
||||
|
||||
/// The type of the demoted visitor type
|
||||
using visitor_t = Visitor;
|
||||
|
||||
@ -169,8 +169,7 @@ struct flat_arraylizer {
|
||||
/// Deduces to the array type when the array is instantiated
|
||||
/// with the given arguments.
|
||||
template <typename First, typename... Rest>
|
||||
using array_type_of_t =
|
||||
Type<typename std::decay<First>::type, 1 + sizeof...(Rest)>;
|
||||
using array_type_of_t = Type<std::decay_t<First>, 1 + sizeof...(Rest)>;
|
||||
|
||||
// We overload with one argument here so Clang and GCC don't
|
||||
// have any issues with overloading against zero arguments.
|
||||
@ -407,9 +406,8 @@ using element_of_t = typename std::conditional<
|
||||
/// Removes all qualifier and references from the given type
|
||||
/// if the type is a l-value or r-value reference.
|
||||
template <typename T>
|
||||
using dereferenced_of_t =
|
||||
typename std::conditional<std::is_reference<T>::value,
|
||||
typename std::decay<T>::type, T>::type;
|
||||
using dereferenced_of_t = typename std::conditional<std::is_reference<T>::value,
|
||||
std::decay_t<T>, T>::type;
|
||||
|
||||
/// Returns the type which is resulting if the mapping is applied to
|
||||
/// an element in the container.
|
||||
@ -423,8 +421,8 @@ using mapped_type_from_t = dereferenced_of_t<spreading::unpacked_of_t<decltype(
|
||||
|
||||
/// Deduces to a true_type if the mapping maps to zero elements.
|
||||
template <typename T, typename M>
|
||||
using is_empty_mapped = spreading::is_empty_spread<typename std::decay<decltype(
|
||||
std::declval<M>()(std::declval<element_of_t<T>>()))>::type>;
|
||||
using is_empty_mapped = spreading::is_empty_spread<
|
||||
std::decay_t<decltype(std::declval<M>()(std::declval<element_of_t<T>>()))>>;
|
||||
|
||||
/// We are allowed to reuse the container if we map to the same
|
||||
/// type we are accepting and when we have
|
||||
@ -472,10 +470,9 @@ template <typename M, typename T>
|
||||
auto remap_container(container_mapping_tag<false, false>, M&& mapper,
|
||||
T&& container)
|
||||
-> decltype(rebind_container<mapped_type_from_t<T, M>>(container)) {
|
||||
static_assert(
|
||||
has_push_back<typename std::decay<T>::type, element_of_t<T>>::value,
|
||||
"Can only remap containers that provide a push_back "
|
||||
"method!");
|
||||
static_assert(has_push_back<std::decay_t<T>, element_of_t<T>>::value,
|
||||
"Can only remap containers that provide a push_back "
|
||||
"method!");
|
||||
|
||||
// Create the new container, which is capable of holding
|
||||
// the remappped types.
|
||||
@ -503,7 +500,7 @@ auto remap_container(container_mapping_tag<false, false>, M&& mapper,
|
||||
/// type we accepted such as int -> int.
|
||||
template <typename M, typename T>
|
||||
auto remap_container(container_mapping_tag<false, true>, M&& mapper,
|
||||
T&& container) -> typename std::decay<T>::type {
|
||||
T&& container) -> std::decay_t<T> {
|
||||
for (auto&& val : container_accessor_of(std::forward<T>(container))) {
|
||||
val = spreading::unpack(
|
||||
std::forward<M>(mapper)(std::forward<decltype(val)>(val)));
|
||||
@ -629,12 +626,11 @@ struct tuple_like_remapper<
|
||||
/// different types.
|
||||
template <typename Strategy, typename T, typename M>
|
||||
auto remap(Strategy, T&& container, M&& mapper) -> decltype(traits::unpack(
|
||||
std::declval<tuple_like_remapper<Strategy, typename std::decay<M>::type,
|
||||
typename std::decay<T>::type>>(),
|
||||
std::declval<
|
||||
tuple_like_remapper<Strategy, std::decay_t<M>, std::decay_t<T>>>(),
|
||||
std::forward<T>(container))) {
|
||||
return traits::unpack(
|
||||
tuple_like_remapper<Strategy, typename std::decay<M>::type,
|
||||
typename std::decay<T>::type>{
|
||||
tuple_like_remapper<Strategy, std::decay_t<M>, std::decay_t<T>>{
|
||||
std::forward<M>(mapper)},
|
||||
std::forward<T>(container));
|
||||
}
|
||||
@ -645,7 +641,7 @@ auto remap(Strategy, T&& container, M&& mapper) -> decltype(traits::unpack(
|
||||
template <typename Strategy>
|
||||
struct mapping_strategy_base {
|
||||
template <typename T>
|
||||
auto may_void(T&& element) const -> typename std::decay<T>::type {
|
||||
auto may_void(T&& element) const -> std::decay_t<T> {
|
||||
return std::forward<T>(element);
|
||||
}
|
||||
};
|
||||
@ -803,19 +799,19 @@ class mapping_helper : protected mapping_strategy_base<Strategy> {
|
||||
template <typename T>
|
||||
auto traverse(Strategy, T&& element)
|
||||
-> decltype(std::declval<mapping_helper>().match(
|
||||
std::declval<container_category_of_t<typename std::decay<T>::type>>(),
|
||||
std::declval<container_category_of_t<std::decay_t<T>>>(),
|
||||
std::declval<T>()));
|
||||
|
||||
/// \copybrief traverse
|
||||
template <typename T>
|
||||
auto try_traverse(Strategy, T&& element)
|
||||
-> decltype(std::declval<mapping_helper>().try_match(
|
||||
std::declval<container_category_of_t<typename std::decay<T>::type>>(),
|
||||
std::declval<container_category_of_t<std::decay_t<T>>>(),
|
||||
std::declval<T>())) {
|
||||
// We use tag dispatching here, to categorize the type T whether
|
||||
// it satisfies the container or tuple like requirements.
|
||||
// Then we can choose the underlying implementation accordingly.
|
||||
return try_match(container_category_of_t<typename std::decay<T>::type>{},
|
||||
return try_match(container_category_of_t<std::decay_t<T>>{},
|
||||
std::forward<T>(element));
|
||||
}
|
||||
|
||||
@ -861,7 +857,7 @@ public:
|
||||
/// Traverses the given pack with the given mapper and strategy
|
||||
template <typename Strategy, typename Mapper, typename... T>
|
||||
decltype(auto) transform(Strategy strategy, Mapper&& mapper, T&&... pack) {
|
||||
mapping_helper<Strategy, typename std::decay<Mapper>::type> helper(
|
||||
mapping_helper<Strategy, std::decay_t<Mapper>> helper(
|
||||
std::forward<Mapper>(mapper));
|
||||
return helper.init_traverse(strategy, std::forward<T>(pack)...);
|
||||
}
|
||||
|
||||
@ -43,8 +43,8 @@ using cti::async_traverse_complete_tag;
|
||||
using cti::async_traverse_detach_tag;
|
||||
using cti::async_traverse_in_place_tag;
|
||||
using cti::async_traverse_visit_tag;
|
||||
using cti::detail::util::unused;
|
||||
using cti::traverse_pack_async;
|
||||
using cti::detail::util::unused;
|
||||
|
||||
/// A tag which isn't accepted by any mapper
|
||||
struct not_accepted_tag {};
|
||||
@ -248,7 +248,7 @@ TEST(async_traversal_tuple_like, visit_tuple_huge) {
|
||||
}
|
||||
|
||||
template <typename T, typename... Args,
|
||||
typename Vector = std::vector<typename std::decay<T>::type>>
|
||||
typename Vector = std::vector<std::decay_t<T>>>
|
||||
Vector vector_of(T&& first, Args&&... args) {
|
||||
return Vector{std::forward<T>(first), std::forward<Args>(args)...};
|
||||
}
|
||||
|
||||
@ -331,9 +331,9 @@ public:
|
||||
: counter_(counter) {
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if<
|
||||
std::is_same<typename std::decay<T>::type,
|
||||
test_tag_1>::value>::type* = nullptr>
|
||||
template <typename T,
|
||||
typename std::enable_if<std::is_same<
|
||||
std::decay_t<T>, test_tag_1>::value>::type* = nullptr>
|
||||
void operator()(T) {
|
||||
++counter_.get();
|
||||
}
|
||||
@ -609,13 +609,13 @@ TEST(test_strategic_container_traverse, every_element_remapped_rvalue) {
|
||||
container.push_back(std::unique_ptr<std::unique_ptr<int>>(
|
||||
new std::unique_ptr<int>(new int(7))));
|
||||
|
||||
std::vector<std::unique_ptr<int>> res = map_pack(
|
||||
[](std::unique_ptr<std::unique_ptr<int>> &
|
||||
ref) -> std::unique_ptr<int>&& {
|
||||
std::vector<std::unique_ptr<int>> res =
|
||||
map_pack([](std::unique_ptr<std::unique_ptr<int>> &
|
||||
ref) -> std::unique_ptr<int>&& {
|
||||
// ...
|
||||
return std::move(*ref);
|
||||
},
|
||||
container);
|
||||
container);
|
||||
|
||||
EXPECT_EQ(res.size(), 1U);
|
||||
EXPECT_EQ((*res[0]), 7);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user