Cycling74 / min-devkit

Tools, documentation, and reference implementation of a Max Package built using the Min-API.
MIT License
163 stars 32 forks source link

error in wiki for creating ins/outs at runtime #130

Closed jamesb93 closed 5 years ago

jamesb93 commented 5 years ago

The wiki currently has a method of creating inlets and outlets at instantiation which throws errors when compiling.

for (auto i=0; i < inlet_count; ++i) { auto an_inlet = std::make_unique<inlet<>>(this, "(bang) my assist message") m_inlets.push_back( an_inlet ); }

First, there should be a ; after the first line inside the loop. Second, using this snippet throws errors:

call to implicitly-deleted copy constructor of 'std::__1::unique_ptr<c74::min::outlet<c74::min::thread_check::any, c74::min::thread_action::assert>, std::__1::default_delete<c74::min::outlet<c74::min::thread_check::any, c74::min::thread_action::assert> > >' ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);

and an easier way (that I have verified compiles but doesn't necessarily work)

for (number i=0; i < outlet_count; i++) { m_outlets.push_back(std::make_unique<outlet<>>(this, "directed message")); }

In addition to this, how does one refer to the outlets created and stored in the vector?

I've tried to do this with indexing and using the -> operator but it causes crashes and my sense is that this refers to nullptrs.

tap commented 5 years ago

It took me a while to find this because it isn't actually in the wiki but in the documentation page "Writing Objects".

You are absolutely correct that a semicolon went missing in those examples -- thanks for reporting!

Your way should also work. For clarity I prefer to keep the two operations on separate lines.

The fix to the doc source is in this commit: https://github.com/Cycling74/min-api/commit/b5a16eaf7b58b4e426cb45edf1bff2b79e42b83f

Thanks!

jamesb93 commented 5 years ago

Thanks for fixing! Since, I have been able to achieve what I need to.