Combine std::tuple/std::pair logic

The std::pair caster can be written as a special case of the std::tuple
caster; this combines them via a base `tuple_caster` class (which is
essentially identical to the previous std::tuple caster).

This also removes the special empty tuple base case: returning an empty
tuple is relatively rare, and the base case still works perfectly well
even when the tuple types is an empty list.
This commit is contained in:
Jason Rhinelander
2017-07-04 14:57:41 -04:00
parent 23bf894590
commit 897d71687e
3 changed files with 14 additions and 48 deletions

View File

@@ -85,7 +85,7 @@ TEST_SUBMODULE(builtin_casters, m) {
m.def("tuple_passthrough", [](std::tuple<bool, std::string, int> input) {
return std::make_tuple(std::get<2>(input), std::get<1>(input), std::get<0>(input));
}, "Return a triple in reversed order");
m.def("empty_tuple", []() { return std::tuple<>(); });
// test_builtins_cast_return_none
m.def("return_none_string", []() -> std::string * { return nullptr; });