c++ - Casting operator-overloading to return 2-dim array to access external library -


class m33 { public:     double m[3][3];      double (*getm())[3] {         return m;     } };  // call jpl cspice f2c generated routine // void mxm_c ( const double   m1  [3][3], //              const double   m2  [3][3], //              double         mout[3][3] )  void test() {     m33 m1;     m33 m2;     m33 mout;     mxm_c( m1.m, m2.m, mout.m ); // works     mxm_c( m1.getm(), m2.getm(), mout.getm() ); // works } 

using vs2013. question: possible use casting operator such as...

operator double*[3] () // not compile {     return m; } 

thereby allowing coding style shortcut?

mxm_c( m1, m2, mout ); // not work 

yes, can such operator. when complex types involved, it's best introduce alias:

using ptr = double (*)[3];  operator ptr() {     return getm(); } 

[live example]


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -