Skip to content

Commit 464a6b4

Browse files
authored
Merge pull request #238 from elbeno/funcptr-tuple
🐛 Fix `make_tuple` with function pointers
2 parents 4eb6a2b + a5f1e4f commit 464a6b4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

include/stdx/tuple.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ template <typename T, tuplelike Tuple>
444444
}
445445

446446
template <typename... Ts> [[nodiscard]] constexpr auto make_tuple(Ts &&...ts) {
447-
return tuple<std::remove_cvref_t<Ts>...>{std::forward<Ts>(ts)...};
447+
return tuple<std::decay_t<Ts>...>{std::forward<Ts>(ts)...};
448448
}
449449

450450
template <template <typename> typename... Fs>

test/tuple.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ TEST_CASE("tuple of lvalue references", "[tuple]") {
141141

142142
TEST_CASE("tuple of lambdas", "[tuple]") {
143143
auto x = 1;
144-
auto t = stdx::make_tuple([&] { x += 2; }, [&] { x += 3; });
144+
auto t = stdx::tuple{[&] { x += 2; }, [&] { x += 3; }};
145145
get<0>(t)();
146146
CHECK(x == 3);
147147
}
@@ -392,9 +392,15 @@ TEST_CASE("copy/move behavior for tuple", "[tuple]") {
392392
CHECK(counter::copies == 0);
393393
}
394394

395+
auto func_no_args() -> void;
396+
auto func_one_arg(int) -> void;
397+
395398
TEST_CASE("make_tuple", "[tuple]") {
396399
STATIC_REQUIRE(stdx::make_tuple() == stdx::tuple{});
397400
STATIC_REQUIRE(stdx::make_tuple(1, 2, 3) == stdx::tuple{1, 2, 3});
401+
STATIC_REQUIRE(
402+
std::is_same_v<decltype(stdx::make_tuple(func_no_args, func_one_arg)),
403+
stdx::tuple<void (*)(), void (*)(int)>>);
398404

399405
constexpr auto t = stdx::make_tuple(stdx::tuple{});
400406
using T = std::remove_const_t<decltype(t)>;

0 commit comments

Comments
 (0)