Skip to content

Commit d077c84

Browse files
authored
[orc-rt] Host std::decay_t out of helper for orc_rt::bind_front. NFC. (#157785)
The helper implementation shouldn't differ based on how it's initialized.
1 parent 735522a commit d077c84

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

orc-rt/include/orc-rt/bind.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,27 @@ template <typename Fn, typename... BoundArgTs> class BoundFn {
2929
}
3030

3131
public:
32-
BoundFn(Fn &&F, BoundArgTs &&...BoundArgs)
33-
: F(std::move(F)), BoundArgs(std::forward<BoundArgTs>(BoundArgs)...) {}
32+
template <typename FnInit, typename... BoundArgInitTs>
33+
BoundFn(FnInit &&F, BoundArgInitTs &&...BoundArgs)
34+
: F(std::forward<FnInit>(F)),
35+
BoundArgs(std::forward<BoundArgInitTs>(BoundArgs)...) {}
3436

3537
template <typename... ArgTs> auto operator()(ArgTs &&...Args) {
3638
return callExpandingBound(std::index_sequence_for<BoundArgTs...>(),
3739
std::forward<ArgTs>(Args)...);
3840
}
3941

4042
private:
41-
std::decay_t<Fn> F;
42-
std::tuple<std::decay_t<BoundArgTs>...> BoundArgs;
43+
Fn F;
44+
std::tuple<BoundArgTs...> BoundArgs;
4345
};
4446

4547
} // namespace detail
4648

4749
template <typename Fn, typename... BoundArgTs>
48-
detail::BoundFn<Fn, BoundArgTs...> bind_front(Fn &&F,
49-
BoundArgTs &&...BoundArgs) {
50-
return detail::BoundFn<Fn, BoundArgTs...>(
50+
detail::BoundFn<std::decay_t<Fn>, std::decay_t<BoundArgTs>...>
51+
bind_front(Fn &&F, BoundArgTs &&...BoundArgs) {
52+
return detail::BoundFn<std::decay_t<Fn>, std::decay_t<BoundArgTs>...>(
5153
std::forward<Fn>(F), std::forward<BoundArgTs>(BoundArgs)...);
5254
}
5355

0 commit comments

Comments
 (0)