Skip to content

Commit

Permalink
Merge pull request #16 from stephenswat/feat/parameter_pack_for
Browse files Browse the repository at this point in the history
Add `make_parameter_pack_for` utility function
  • Loading branch information
stephenswat authored Oct 21, 2023
2 parents 72626b1 + fe60588 commit 73fa828
Show file tree
Hide file tree
Showing 3 changed files with 401 additions and 0 deletions.
8 changes: 8 additions & 0 deletions extra/parameter_pack_gen/gen_parameter_pack_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if __name__ == "__main__":
for n in range(1, 11):
print(f"template <typename F, std::enable_if_t<utility::backend_depth<typename F::backend_t>::value == {n}, bool> = true> auto make_parameter_pack_for(")
print(",".join(f"typename utility::nth_backend<typename F::backend_t, {i}>::type::configuration_t && a{i}" for i in range(n)))
print(") { return make_parameter_pack(")
print(",".join(f"std::forward<typename utility::nth_backend<typename F::backend_t, {i}>::type::configuration_t>(a{i})" for i in range(n)))
print(");}")
print()
344 changes: 344 additions & 0 deletions lib/core/covfie/core/parameter_pack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <utility>

#include <covfie/core/utility/backend_traits.hpp>

namespace covfie {
template <typename... Ts>
class parameter_pack
Expand Down Expand Up @@ -46,4 +48,346 @@ parameter_pack<Ts...> make_parameter_pack(Ts &&... args)
{
return parameter_pack<Ts...>(std::forward<Ts>(args)...);
}

// WARNING: These functions are automatically generated. Best not edit them
// by hand.

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 1,
bool> = true>
auto make_parameter_pack_for(typename utility::nth_backend<
typename F::backend_t,
0>::type::configuration_t && a0)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0)
);
}

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 2,
bool> = true>
auto make_parameter_pack_for(
typename utility::nth_backend<typename F::backend_t, 0>::type::
configuration_t && a0,
typename utility::nth_backend<typename F::backend_t, 1>::type::
configuration_t && a1
)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0),
std::forward<typename utility::nth_backend<typename F::backend_t, 1>::
type::configuration_t>(a1)
);
}

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 3,
bool> = true>
auto make_parameter_pack_for(
typename utility::nth_backend<typename F::backend_t, 0>::type::
configuration_t && a0,
typename utility::nth_backend<typename F::backend_t, 1>::type::
configuration_t && a1,
typename utility::nth_backend<typename F::backend_t, 2>::type::
configuration_t && a2
)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0),
std::forward<typename utility::nth_backend<typename F::backend_t, 1>::
type::configuration_t>(a1),
std::forward<typename utility::nth_backend<typename F::backend_t, 2>::
type::configuration_t>(a2)
);
}

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 4,
bool> = true>
auto make_parameter_pack_for(
typename utility::nth_backend<typename F::backend_t, 0>::type::
configuration_t && a0,
typename utility::nth_backend<typename F::backend_t, 1>::type::
configuration_t && a1,
typename utility::nth_backend<typename F::backend_t, 2>::type::
configuration_t && a2,
typename utility::nth_backend<typename F::backend_t, 3>::type::
configuration_t && a3
)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0),
std::forward<typename utility::nth_backend<typename F::backend_t, 1>::
type::configuration_t>(a1),
std::forward<typename utility::nth_backend<typename F::backend_t, 2>::
type::configuration_t>(a2),
std::forward<typename utility::nth_backend<typename F::backend_t, 3>::
type::configuration_t>(a3)
);
}

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 5,
bool> = true>
auto make_parameter_pack_for(
typename utility::nth_backend<typename F::backend_t, 0>::type::
configuration_t && a0,
typename utility::nth_backend<typename F::backend_t, 1>::type::
configuration_t && a1,
typename utility::nth_backend<typename F::backend_t, 2>::type::
configuration_t && a2,
typename utility::nth_backend<typename F::backend_t, 3>::type::
configuration_t && a3,
typename utility::nth_backend<typename F::backend_t, 4>::type::
configuration_t && a4
)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0),
std::forward<typename utility::nth_backend<typename F::backend_t, 1>::
type::configuration_t>(a1),
std::forward<typename utility::nth_backend<typename F::backend_t, 2>::
type::configuration_t>(a2),
std::forward<typename utility::nth_backend<typename F::backend_t, 3>::
type::configuration_t>(a3),
std::forward<typename utility::nth_backend<typename F::backend_t, 4>::
type::configuration_t>(a4)
);
}

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 6,
bool> = true>
auto make_parameter_pack_for(
typename utility::nth_backend<typename F::backend_t, 0>::type::
configuration_t && a0,
typename utility::nth_backend<typename F::backend_t, 1>::type::
configuration_t && a1,
typename utility::nth_backend<typename F::backend_t, 2>::type::
configuration_t && a2,
typename utility::nth_backend<typename F::backend_t, 3>::type::
configuration_t && a3,
typename utility::nth_backend<typename F::backend_t, 4>::type::
configuration_t && a4,
typename utility::nth_backend<typename F::backend_t, 5>::type::
configuration_t && a5
)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0),
std::forward<typename utility::nth_backend<typename F::backend_t, 1>::
type::configuration_t>(a1),
std::forward<typename utility::nth_backend<typename F::backend_t, 2>::
type::configuration_t>(a2),
std::forward<typename utility::nth_backend<typename F::backend_t, 3>::
type::configuration_t>(a3),
std::forward<typename utility::nth_backend<typename F::backend_t, 4>::
type::configuration_t>(a4),
std::forward<typename utility::nth_backend<typename F::backend_t, 5>::
type::configuration_t>(a5)
);
}

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 7,
bool> = true>
auto make_parameter_pack_for(
typename utility::nth_backend<typename F::backend_t, 0>::type::
configuration_t && a0,
typename utility::nth_backend<typename F::backend_t, 1>::type::
configuration_t && a1,
typename utility::nth_backend<typename F::backend_t, 2>::type::
configuration_t && a2,
typename utility::nth_backend<typename F::backend_t, 3>::type::
configuration_t && a3,
typename utility::nth_backend<typename F::backend_t, 4>::type::
configuration_t && a4,
typename utility::nth_backend<typename F::backend_t, 5>::type::
configuration_t && a5,
typename utility::nth_backend<typename F::backend_t, 6>::type::
configuration_t && a6
)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0),
std::forward<typename utility::nth_backend<typename F::backend_t, 1>::
type::configuration_t>(a1),
std::forward<typename utility::nth_backend<typename F::backend_t, 2>::
type::configuration_t>(a2),
std::forward<typename utility::nth_backend<typename F::backend_t, 3>::
type::configuration_t>(a3),
std::forward<typename utility::nth_backend<typename F::backend_t, 4>::
type::configuration_t>(a4),
std::forward<typename utility::nth_backend<typename F::backend_t, 5>::
type::configuration_t>(a5),
std::forward<typename utility::nth_backend<typename F::backend_t, 6>::
type::configuration_t>(a6)
);
}

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 8,
bool> = true>
auto make_parameter_pack_for(
typename utility::nth_backend<typename F::backend_t, 0>::type::
configuration_t && a0,
typename utility::nth_backend<typename F::backend_t, 1>::type::
configuration_t && a1,
typename utility::nth_backend<typename F::backend_t, 2>::type::
configuration_t && a2,
typename utility::nth_backend<typename F::backend_t, 3>::type::
configuration_t && a3,
typename utility::nth_backend<typename F::backend_t, 4>::type::
configuration_t && a4,
typename utility::nth_backend<typename F::backend_t, 5>::type::
configuration_t && a5,
typename utility::nth_backend<typename F::backend_t, 6>::type::
configuration_t && a6,
typename utility::nth_backend<typename F::backend_t, 7>::type::
configuration_t && a7
)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0),
std::forward<typename utility::nth_backend<typename F::backend_t, 1>::
type::configuration_t>(a1),
std::forward<typename utility::nth_backend<typename F::backend_t, 2>::
type::configuration_t>(a2),
std::forward<typename utility::nth_backend<typename F::backend_t, 3>::
type::configuration_t>(a3),
std::forward<typename utility::nth_backend<typename F::backend_t, 4>::
type::configuration_t>(a4),
std::forward<typename utility::nth_backend<typename F::backend_t, 5>::
type::configuration_t>(a5),
std::forward<typename utility::nth_backend<typename F::backend_t, 6>::
type::configuration_t>(a6),
std::forward<typename utility::nth_backend<typename F::backend_t, 7>::
type::configuration_t>(a7)
);
}

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 9,
bool> = true>
auto make_parameter_pack_for(
typename utility::nth_backend<typename F::backend_t, 0>::type::
configuration_t && a0,
typename utility::nth_backend<typename F::backend_t, 1>::type::
configuration_t && a1,
typename utility::nth_backend<typename F::backend_t, 2>::type::
configuration_t && a2,
typename utility::nth_backend<typename F::backend_t, 3>::type::
configuration_t && a3,
typename utility::nth_backend<typename F::backend_t, 4>::type::
configuration_t && a4,
typename utility::nth_backend<typename F::backend_t, 5>::type::
configuration_t && a5,
typename utility::nth_backend<typename F::backend_t, 6>::type::
configuration_t && a6,
typename utility::nth_backend<typename F::backend_t, 7>::type::
configuration_t && a7,
typename utility::nth_backend<typename F::backend_t, 8>::type::
configuration_t && a8
)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0),
std::forward<typename utility::nth_backend<typename F::backend_t, 1>::
type::configuration_t>(a1),
std::forward<typename utility::nth_backend<typename F::backend_t, 2>::
type::configuration_t>(a2),
std::forward<typename utility::nth_backend<typename F::backend_t, 3>::
type::configuration_t>(a3),
std::forward<typename utility::nth_backend<typename F::backend_t, 4>::
type::configuration_t>(a4),
std::forward<typename utility::nth_backend<typename F::backend_t, 5>::
type::configuration_t>(a5),
std::forward<typename utility::nth_backend<typename F::backend_t, 6>::
type::configuration_t>(a6),
std::forward<typename utility::nth_backend<typename F::backend_t, 7>::
type::configuration_t>(a7),
std::forward<typename utility::nth_backend<typename F::backend_t, 8>::
type::configuration_t>(a8)
);
}

template <
typename F,
std::enable_if_t<
utility::backend_depth<typename F::backend_t>::value == 10,
bool> = true>
auto make_parameter_pack_for(
typename utility::nth_backend<typename F::backend_t, 0>::type::
configuration_t && a0,
typename utility::nth_backend<typename F::backend_t, 1>::type::
configuration_t && a1,
typename utility::nth_backend<typename F::backend_t, 2>::type::
configuration_t && a2,
typename utility::nth_backend<typename F::backend_t, 3>::type::
configuration_t && a3,
typename utility::nth_backend<typename F::backend_t, 4>::type::
configuration_t && a4,
typename utility::nth_backend<typename F::backend_t, 5>::type::
configuration_t && a5,
typename utility::nth_backend<typename F::backend_t, 6>::type::
configuration_t && a6,
typename utility::nth_backend<typename F::backend_t, 7>::type::
configuration_t && a7,
typename utility::nth_backend<typename F::backend_t, 8>::type::
configuration_t && a8,
typename utility::nth_backend<typename F::backend_t, 9>::type::
configuration_t && a9
)
{
return make_parameter_pack(
std::forward<typename utility::nth_backend<typename F::backend_t, 0>::
type::configuration_t>(a0),
std::forward<typename utility::nth_backend<typename F::backend_t, 1>::
type::configuration_t>(a1),
std::forward<typename utility::nth_backend<typename F::backend_t, 2>::
type::configuration_t>(a2),
std::forward<typename utility::nth_backend<typename F::backend_t, 3>::
type::configuration_t>(a3),
std::forward<typename utility::nth_backend<typename F::backend_t, 4>::
type::configuration_t>(a4),
std::forward<typename utility::nth_backend<typename F::backend_t, 5>::
type::configuration_t>(a5),
std::forward<typename utility::nth_backend<typename F::backend_t, 6>::
type::configuration_t>(a6),
std::forward<typename utility::nth_backend<typename F::backend_t, 7>::
type::configuration_t>(a7),
std::forward<typename utility::nth_backend<typename F::backend_t, 8>::
type::configuration_t>(a8),
std::forward<typename utility::nth_backend<typename F::backend_t, 9>::
type::configuration_t>(a9)
);
}
}
Loading

0 comments on commit 73fa828

Please sign in to comment.