Skip to content

Commit

Permalink
Switching to using decltype in HPX_CAPTURE_FORWARD
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Jan 5, 2018
1 parent cc466cb commit ff2817d
Show file tree
Hide file tree
Showing 29 changed files with 80 additions and 82 deletions.
8 changes: 4 additions & 4 deletions hpx/config/lambda_capture.hpp
Expand Up @@ -11,11 +11,11 @@
#include <utility>

#if defined(HPX_HAVE_CXX14_LAMBDAS)
#define HPX_CAPTURE_FORWARD(var, type) var = std::forward<type>(var)
#define HPX_CAPTURE_MOVE(var) var = std::move(var)
#define HPX_CAPTURE_FORWARD(var) var = std::forward<decltype(var)>(var)
#define HPX_CAPTURE_MOVE(var) var = std::move(var)
#else
#define HPX_CAPTURE_FORWARD(var, type) var
#define HPX_CAPTURE_MOVE(var) var
#define HPX_CAPTURE_FORWARD(var) var
#define HPX_CAPTURE_MOVE(var) var
#endif

#endif
4 changes: 2 additions & 2 deletions hpx/lcos/future.hpp
Expand Up @@ -1125,7 +1125,7 @@ namespace hpx { namespace lcos
convert_future_helper(Future && f, Conv && conv) //-V659
{
return f.then(
[HPX_CAPTURE_FORWARD(conv, Conv)](Future && f) -> T
[HPX_CAPTURE_FORWARD(conv)](Future && f) -> T
{
return hpx::util::invoke(conv, f.get());
});
Expand Down Expand Up @@ -1426,7 +1426,7 @@ namespace hpx { namespace lcos
"result type by using the supplied conversion function");

return f.then(
[HPX_CAPTURE_FORWARD(conv, Conv)](hpx::shared_future<U> const& f)
[HPX_CAPTURE_FORWARD(conv)](hpx::shared_future<U> const& f)
{
return hpx::util::invoke(conv, f.get());
});
Expand Down
2 changes: 1 addition & 1 deletion hpx/parallel/algorithms/adjacent_difference.hpp
Expand Up @@ -78,7 +78,7 @@ namespace hpx { namespace parallel { inline namespace v1
}

auto f1 =
[HPX_CAPTURE_FORWARD(op, Op)](
[HPX_CAPTURE_FORWARD(op)](
zip_iterator part_begin, std::size_t part_size) mutable
{
// VS2015RC bails out when op is captured by ref
Expand Down
2 changes: 1 addition & 1 deletion hpx/parallel/algorithms/adjacent_find.hpp
Expand Up @@ -76,7 +76,7 @@ namespace hpx { namespace parallel { inline namespace v1
call_with_index(
std::forward<ExPolicy>(policy),
hpx::util::make_zip_iterator(first, next), count-1, 1,
[HPX_CAPTURE_FORWARD(op, Pred), tok](
[HPX_CAPTURE_FORWARD(op), tok](
zip_iterator it, std::size_t part_size,
std::size_t base_idx) mutable
{
Expand Down
12 changes: 6 additions & 6 deletions hpx/parallel/algorithms/all_any_none.hpp
Expand Up @@ -72,8 +72,8 @@ namespace hpx { namespace parallel { inline namespace v1

util::cancellation_token<> tok;
auto f1 =
[HPX_CAPTURE_FORWARD(op, F), tok,
HPX_CAPTURE_FORWARD(proj, Proj)
[HPX_CAPTURE_FORWARD(op), tok,
HPX_CAPTURE_FORWARD(proj)
](FwdIter part_begin, std::size_t part_count) mutable -> bool
{
util::loop_n<ExPolicy>(part_begin, part_count, tok,
Expand Down Expand Up @@ -247,8 +247,8 @@ namespace hpx { namespace parallel { inline namespace v1

util::cancellation_token<> tok;
auto f1 =
[HPX_CAPTURE_FORWARD(op, F), tok,
HPX_CAPTURE_FORWARD(proj, Proj)
[HPX_CAPTURE_FORWARD(op), tok,
HPX_CAPTURE_FORWARD(proj)
](FwdIter part_begin, std::size_t part_count) mutable -> bool
{
util::loop_n<ExPolicy>(
Expand Down Expand Up @@ -423,8 +423,8 @@ namespace hpx { namespace parallel { inline namespace v1

util::cancellation_token<> tok;
auto f1 =
[HPX_CAPTURE_FORWARD(op, F), tok,
HPX_CAPTURE_FORWARD(proj, Proj)
[HPX_CAPTURE_FORWARD(op), tok,
HPX_CAPTURE_FORWARD(proj)
](FwdIter part_begin, std::size_t part_count) mutable -> bool
{
util::loop_n<ExPolicy>(
Expand Down
4 changes: 2 additions & 2 deletions hpx/parallel/algorithms/copy.hpp
Expand Up @@ -423,8 +423,8 @@ namespace hpx { namespace parallel { inline namespace v1
> scan_partitioner_type;

auto f1 =
[HPX_CAPTURE_FORWARD(pred, Pred),
HPX_CAPTURE_FORWARD(proj, Proj)
[HPX_CAPTURE_FORWARD(pred),
HPX_CAPTURE_FORWARD(proj)
](zip_iterator part_begin, std::size_t part_size)
-> std::size_t
{
Expand Down
2 changes: 1 addition & 1 deletion hpx/parallel/algorithms/exclusive_scan.hpp
Expand Up @@ -148,7 +148,7 @@ namespace hpx { namespace parallel { inline namespace v1
std::forward<ExPolicy>(policy),
make_zip_iterator(first, dest), count, init,
// step 1 performs first part of scan algorithm
[op, HPX_CAPTURE_FORWARD(conv, Conv), last](
[op, HPX_CAPTURE_FORWARD(conv), last](
zip_iterator part_begin, std::size_t part_size) -> T
{
T part_init = hpx::util::invoke(
Expand Down
8 changes: 4 additions & 4 deletions hpx/parallel/algorithms/find.hpp
Expand Up @@ -224,7 +224,7 @@ namespace hpx { namespace parallel { inline namespace v1
return util::partitioner<ExPolicy, FwdIter, void>::
call_with_index(
std::forward<ExPolicy>(policy), first, count, 1,
[HPX_CAPTURE_FORWARD(f, F), tok](
[HPX_CAPTURE_FORWARD(f), tok](
FwdIter it, std::size_t part_size,
std::size_t base_idx
) mutable -> void
Expand Down Expand Up @@ -400,7 +400,7 @@ namespace hpx { namespace parallel { inline namespace v1
return util::partitioner<ExPolicy, FwdIter, void>::
call_with_index(
std::forward<ExPolicy>(policy), first, count, 1,
[HPX_CAPTURE_FORWARD(f, F), tok](
[HPX_CAPTURE_FORWARD(f), tok](
FwdIter it, std::size_t part_size,
std::size_t base_idx
) mutable -> void
Expand Down Expand Up @@ -579,7 +579,7 @@ namespace hpx { namespace parallel { inline namespace v1
return util::partitioner<ExPolicy, FwdIter, void>::
call_with_index(std::forward<ExPolicy>(policy),
first1, count - diff + 1, 1,
[=, HPX_CAPTURE_FORWARD(op, Pred)](
[=, HPX_CAPTURE_FORWARD(op)](
FwdIter it, std::size_t part_size,
std::size_t base_idx
) mutable -> void
Expand Down Expand Up @@ -784,7 +784,7 @@ namespace hpx { namespace parallel { inline namespace v1
return util::partitioner<ExPolicy, FwdIter, void>::
call_with_index(
std::forward<ExPolicy>(policy), first, count, 1,
[s_first, s_last, tok, HPX_CAPTURE_FORWARD(op, Pred)](
[s_first, s_last, tok, HPX_CAPTURE_FORWARD(op)](
FwdIter it, std::size_t part_size,
std::size_t base_idx
) mutable -> void
Expand Down
4 changes: 2 additions & 2 deletions hpx/parallel/algorithms/generate.hpp
Expand Up @@ -58,7 +58,7 @@ namespace hpx { namespace parallel { inline namespace v1
return for_each_n<FwdIter>().call(
std::forward<ExPolicy>(policy), std::false_type(),
first, std::distance(first, last),
[HPX_CAPTURE_FORWARD(f, F)](type& v) mutable
[HPX_CAPTURE_FORWARD(f)](type& v) mutable
{
v = f();
},
Expand Down Expand Up @@ -192,7 +192,7 @@ namespace hpx { namespace parallel { inline namespace v1
for_each_n<FwdIter>().call(
std::forward<ExPolicy>(policy),
std::false_type(), first, count,
[HPX_CAPTURE_FORWARD(f, F)](type& v) mutable
[HPX_CAPTURE_FORWARD(f)](type& v) mutable
{
v = f();
},
Expand Down
2 changes: 1 addition & 1 deletion hpx/parallel/algorithms/includes.hpp
Expand Up @@ -153,7 +153,7 @@ namespace hpx { namespace parallel { inline namespace v1
std::forward<ExPolicy>(policy),
first2, std::distance(first2, last2),
[first1, last1, first2, last2, tok,
HPX_CAPTURE_FORWARD(f, F)
HPX_CAPTURE_FORWARD(f)
](FwdIter2 part_begin, std::size_t part_count) mutable
-> bool
{
Expand Down
2 changes: 1 addition & 1 deletion hpx/parallel/algorithms/inclusive_scan.hpp
Expand Up @@ -144,7 +144,7 @@ namespace hpx { namespace parallel { inline namespace v1
std::forward<ExPolicy>(policy),
make_zip_iterator(first, dest), count, init,
// step 1 performs first part of scan algorithm
[op, last, HPX_CAPTURE_FORWARD(conv, Conv)](
[op, last, HPX_CAPTURE_FORWARD(conv)](
zip_iterator part_begin, std::size_t part_size) -> T
{
T part_init = hpx::util::invoke(conv, get<0>(*part_begin));
Expand Down
8 changes: 4 additions & 4 deletions hpx/parallel/algorithms/is_heap.hpp
Expand Up @@ -85,8 +85,8 @@ namespace hpx { namespace parallel { inline namespace v1
call_with_index(
std::forward<ExPolicy>(policy), second, count, 1,
[tok, first,
HPX_CAPTURE_FORWARD(comp, Comp),
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(comp),
HPX_CAPTURE_FORWARD(proj)
](RandIter it, std::size_t part_size,
std::size_t base_idx
) mutable -> void
Expand Down Expand Up @@ -284,8 +284,8 @@ namespace hpx { namespace parallel { inline namespace v1
call_with_index(
std::forward<ExPolicy>(policy), second, count, 1,
[tok, first,
HPX_CAPTURE_FORWARD(comp, Comp),
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(comp),
HPX_CAPTURE_FORWARD(proj)
](RandIter it, std::size_t part_size,
std::size_t base_idx) mutable
{
Expand Down
2 changes: 1 addition & 1 deletion hpx/parallel/algorithms/is_partitioned.hpp
Expand Up @@ -89,7 +89,7 @@ namespace hpx { namespace parallel { inline namespace v1

util::cancellation_token<> tok;
auto f1 =
[tok, HPX_CAPTURE_FORWARD(pred, Pred)](
[tok, HPX_CAPTURE_FORWARD(pred)](
Iter part_begin, std::size_t part_count) mutable -> bool
{
bool fst_bool = hpx::util::invoke(pred, *part_begin);
Expand Down
4 changes: 2 additions & 2 deletions hpx/parallel/algorithms/is_sorted.hpp
Expand Up @@ -65,7 +65,7 @@ namespace hpx { namespace parallel { inline namespace v1

util::cancellation_token<> tok;
auto f1 =
[tok, last, HPX_CAPTURE_FORWARD(pred, Pred)](
[tok, last, HPX_CAPTURE_FORWARD(pred)](
FwdIter part_begin, std::size_t part_size
) mutable -> bool
{
Expand Down Expand Up @@ -226,7 +226,7 @@ namespace hpx { namespace parallel { inline namespace v1
return util::partitioner<ExPolicy, FwdIter, void>::
call_with_index(
std::forward<ExPolicy>(policy), first, count, 1,
[tok, last, HPX_CAPTURE_FORWARD(pred, Pred)](
[tok, last, HPX_CAPTURE_FORWARD(pred)](
FwdIter part_begin, std::size_t part_size,
std::size_t base_idx
) mutable -> void
Expand Down
4 changes: 2 additions & 2 deletions hpx/parallel/algorithms/merge.hpp
Expand Up @@ -680,8 +680,8 @@ namespace hpx { namespace parallel { inline namespace v1
{
return execution::async_execute(
policy.executor(),
[=, HPX_CAPTURE_FORWARD(comp, Comp),
HPX_CAPTURE_FORWARD(proj, Proj)
[=, HPX_CAPTURE_FORWARD(comp),
HPX_CAPTURE_FORWARD(proj)
]() mutable -> RandIter
{
try {
Expand Down
12 changes: 6 additions & 6 deletions hpx/parallel/algorithms/minmax.hpp
Expand Up @@ -134,8 +134,8 @@ namespace hpx { namespace parallel { inline namespace v1
};
auto f2 =
[policy,
HPX_CAPTURE_FORWARD(f, F),
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(f),
HPX_CAPTURE_FORWARD(proj)
](std::vector<FwdIter> && positions) -> FwdIter
{
return min_element::sequential_minmax_element_ind(
Expand Down Expand Up @@ -368,8 +368,8 @@ namespace hpx { namespace parallel { inline namespace v1
};
auto f2 =
[policy,
HPX_CAPTURE_FORWARD(f, F),
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(f),
HPX_CAPTURE_FORWARD(proj)
](std::vector<FwdIter> && positions) -> FwdIter
{
return max_element::sequential_minmax_element_ind(
Expand Down Expand Up @@ -624,8 +624,8 @@ namespace hpx { namespace parallel { inline namespace v1
};
auto f2 =
[policy,
HPX_CAPTURE_FORWARD(f, F),
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(f),
HPX_CAPTURE_FORWARD(proj)
](std::vector<result_type> && positions) -> result_type
{
return minmax_element::sequential_minmax_element_ind(
Expand Down
4 changes: 2 additions & 2 deletions hpx/parallel/algorithms/mismatch.hpp
Expand Up @@ -105,7 +105,7 @@ namespace hpx { namespace parallel { inline namespace v1
call_with_index(
std::forward<ExPolicy>(policy),
hpx::util::make_zip_iterator(first1, first2), count1, 1,
[tok, HPX_CAPTURE_FORWARD(f, F)](
[tok, HPX_CAPTURE_FORWARD(f)](
zip_iterator it, std::size_t part_count,
std::size_t base_idx
) mutable -> void
Expand Down Expand Up @@ -304,7 +304,7 @@ namespace hpx { namespace parallel { inline namespace v1
call_with_index(
std::forward<ExPolicy>(policy),
hpx::util::make_zip_iterator(first1, first2), count, 1,
[tok, HPX_CAPTURE_FORWARD(f, F)](
[tok, HPX_CAPTURE_FORWARD(f)](
zip_iterator it, std::size_t part_count,
std::size_t base_idx
) mutable -> void
Expand Down
12 changes: 5 additions & 7 deletions hpx/parallel/algorithms/partition.hpp
Expand Up @@ -67,8 +67,8 @@ namespace hpx { namespace parallel { inline namespace v1
return execution::async_execute(
policy.executor(),
[first, last,
HPX_CAPTURE_FORWARD(f, F),
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(f),
HPX_CAPTURE_FORWARD(proj)
]() -> RandIter
{
return std::stable_partition(
Expand Down Expand Up @@ -1156,11 +1156,9 @@ namespace hpx { namespace parallel { inline namespace v1
> scan_partitioner_type;

auto f1 =
[HPX_CAPTURE_FORWARD(pred, Pred),
HPX_CAPTURE_FORWARD(proj, Proj)]
(
zip_iterator part_begin, std::size_t part_size
) -> output_iterator_offset
[HPX_CAPTURE_FORWARD(pred), HPX_CAPTURE_FORWARD(proj)](
zip_iterator part_begin, std::size_t part_size)
-> output_iterator_offset
{
std::size_t true_count = 0;

Expand Down
4 changes: 2 additions & 2 deletions hpx/parallel/algorithms/reduce.hpp
Expand Up @@ -76,8 +76,8 @@ namespace hpx { namespace parallel { inline namespace v1
first, std::distance(first, last),
std::move(f1),
hpx::util::unwrapping(
[HPX_CAPTURE_FORWARD(init, T_),
HPX_CAPTURE_FORWARD(r, Reduce)
[HPX_CAPTURE_FORWARD(init),
HPX_CAPTURE_FORWARD(r)
](std::vector<T> && results) -> T
{
return util::accumulate_n(hpx::util::begin(results),
Expand Down
4 changes: 2 additions & 2 deletions hpx/parallel/algorithms/remove.hpp
Expand Up @@ -108,8 +108,8 @@ namespace hpx { namespace parallel { inline namespace v1
> scan_partitioner_type;

auto f1 =
[HPX_CAPTURE_FORWARD(pred, Pred),
HPX_CAPTURE_FORWARD(proj, Proj)
[HPX_CAPTURE_FORWARD(pred),
HPX_CAPTURE_FORWARD(proj)
](zip_iterator part_begin, std::size_t part_size)
-> std::size_t
{
Expand Down
2 changes: 1 addition & 1 deletion hpx/parallel/algorithms/remove_copy.hpp
Expand Up @@ -259,7 +259,7 @@ namespace hpx { namespace parallel { inline namespace v1
return copy_if<IterPair>().call(
std::forward<ExPolicy>(policy), std::false_type(),
first, last, dest,
[HPX_CAPTURE_FORWARD(f, F)](value_type const& a) -> bool
[HPX_CAPTURE_FORWARD(f)](value_type const& a) -> bool
{
return !hpx::util::invoke(f, a);
},
Expand Down
12 changes: 6 additions & 6 deletions hpx/parallel/algorithms/replace.hpp
Expand Up @@ -84,7 +84,7 @@ namespace hpx { namespace parallel { inline namespace v1
std::forward<ExPolicy>(policy), std::false_type(),
first, std::distance(first, last),
[old_value, new_value,
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(proj)
](type& t) -> void
{
if (hpx::util::invoke(proj, t) == old_value)
Expand Down Expand Up @@ -229,8 +229,8 @@ namespace hpx { namespace parallel { inline namespace v1
std::forward<ExPolicy>(policy), std::false_type(),
first, std::distance(first, last),
[new_value,
HPX_CAPTURE_FORWARD(f, F),
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(f),
HPX_CAPTURE_FORWARD(proj)
](type& t) -> void
{
using hpx::util::invoke;
Expand Down Expand Up @@ -396,7 +396,7 @@ namespace hpx { namespace parallel { inline namespace v1
hpx::util::make_zip_iterator(first, dest),
std::distance(first, last),
[old_value, new_value,
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(proj)
](reference t) -> void
{
using hpx::util::get;
Expand Down Expand Up @@ -584,8 +584,8 @@ namespace hpx { namespace parallel { inline namespace v1
hpx::util::make_zip_iterator(first, dest),
std::distance(first, last),
[new_value,
HPX_CAPTURE_FORWARD(f, F),
HPX_CAPTURE_FORWARD(proj, Proj)
HPX_CAPTURE_FORWARD(f),
HPX_CAPTURE_FORWARD(proj)
](reference t) -> void
{
using hpx::util::get;
Expand Down

0 comments on commit ff2817d

Please sign in to comment.