我有一个问题是我最近发布的其他两个问题的延伸:
和
假设我有一个数组A。我想通过启用以下类似 Matlab 的语法来创建一个f作用于并A返回两个其他数组的函数BC
[B,C]=f(A);
在 C++ 中可能吗?
LEEMES 回答后的解决方案
#include <tuple>
using std::tie;
std::tuple<TypeOfB,TypeOfC> f(const Matrix<T1>&a,const Matrix<T2>&a) {
    // Instruction declaring and defining B_temp and C_temp
    return std::make_tuple(B_temp,C_temp); }
int main( int argc, char** argv) 
{
    // Instruction declaring A, B and C
    tie(B,C)=f(A);
    // STUFF
    return 0;
 }
一切都在改变std::tuple和改变make_tuple时std::pair也std::make_pair适用于这种特殊情况(只有两个输出)。