Cycling74 / min-api

High-level C++-language application programming interface for Max
MIT License
57 stars 23 forks source link

Add ability to define limits for `attribute<numbers>` #197

Open isabelgk opened 1 year ago

isabelgk commented 1 year ago

Currently, it's not possible to define attribute<numbers> with a limit. It'd be nice to be able to do something like:

attribute<numbers, threadsafe::no, limit::clamp> m_foo { this, "foo", { 0.0, 0.0 },
    range { {-1.0, 3.5}, {-4.3, 7.0} }
};

This fails because:

error: no matching constructor for initialization of 'c74::min::range' (aka 'vector<c74::min::atom>')
    range { {-1.0, 3.5}, {-4.3, 7.0} }
    ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c74_min_attribute.h:758:13: error: static_assert failed due to requirement 'std::is_arithmetic<std::vector<double, std::allocator<double>>>::value' "limiting can only be applied to arithmetic types"
                   static_assert(std::is_arithmetic<T>::value, "limiting can only be applied to arithmetic types");
                   ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We'd need to: