Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In C++11, you can do this using tuples:</p> <pre><code>std::tuple&lt;some_type, another_type, yet_another_type&gt; ff(...); some_type x; another_type y; yet_another_type z; std::tie(x,y,z) = ff(a,b,c); </code></pre> <p>If your compiler doesn't support that, the <a href="http://www.boost.org/doc/libs/1_49_0/libs/tuple/doc/tuple_users_guide.html" rel="nofollow">Boost.Tuple</a> library is very similar, but may be more restricted without support from variadic templates.</p> <p>If you really want to support syntax like <code>(x,y,z) = ff(a,b,c);</code>, which might be rather confusing to a C++ programmer even if it does look sensible in Matlab, then you're almost there. You need a separate type similar to your <code>ArgList</code> (perhaps called something like <code>RefList</code>), which contains pointers rather than values, initialises these pointers from non-<code>const</code> references to the results, and has an assignment operator that takes an <code>ArgList</code> (or some other collection of values) and assigns each element via the pointers.</p> <p>You might also want to look at <a href="http://www.boost.org/doc/libs/1_49_0/libs/assign/doc/index.html" rel="nofollow">Boost.Assignment</a> to see how that kind of operator overloading can be made to work. It's a bit of a hassle; in particular, you can't overload operators that act only on built-in types, which rather limits the usefulness of that approach. Personally, I'd use variadic templates instead if C++11 is an option.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload