最近投稿した他の 2 つの質問の延長である質問があります。
B および A 配列と B が既に定義されている B=f(A) の実装
と
array があるとしA
ます。次のMatlabのような構文を有効にすることにより、他の2つの配列とにf
作用して返す関数を作成したいと思いますA
B
C
[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;
}
この特定のケース (2 つの出力のみ) をstd::tuple
変更make_tuple
する場合もstd::pair
、すべてが機能します。std::make_pair