Skip to content

Commit

Permalink
[max/pd] Tuple input
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Oct 1, 2024
1 parent 957832f commit 36b08a8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
13 changes: 12 additions & 1 deletion include/avnd/binding/max/from_atoms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,18 @@ struct from_atoms
// FIXME
template<avnd::tuple_ish T>
requires (!avnd::pair_ish<T>)
bool operator()(T& v) const noexcept { return false; }
bool operator()(T& v) const noexcept
{
static constexpr int N = std::tuple_size_v<T>;
if(ac < N)
return false;

[&]<std::size_t... I>(std::index_sequence<I...>) {
(from_atom{av[I]}(std::get<I>(v)), ...);
}(std::make_index_sequence<N>{});

return true;
}


bool operator()(avnd::variant_ish auto& v) const noexcept
Expand Down
19 changes: 15 additions & 4 deletions include/avnd/binding/pd/inputs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#endif

#include <cstring>
#include <cmath>
#include <mutex>
namespace pd
{
Expand Down Expand Up @@ -247,10 +248,20 @@ struct from_atoms
return from_atom{av[0]}(v);
}

// FIXME
template<avnd::tuple_ish T>
requires (!avnd::pair_ish<T>)
bool operator()(T& v) const noexcept { return false; }
template <avnd::tuple_ish T>
requires(!avnd::pair_ish<T>)
bool operator()(T& v) const noexcept
{
static constexpr int N = std::tuple_size_v<T>;
if(ac < N)
return false;

[&]<std::size_t... I>(std::index_sequence<I...>) {
(from_atom{av[I]}(std::get<I>(v)), ...);
}(std::make_index_sequence<N>{});

return true;
}

bool operator()(avnd::variant_ish auto& v) const noexcept
{
Expand Down

0 comments on commit 36b08a8

Please sign in to comment.