Implementing Matlab's colon : operator in C++ expression templates class

前端 未结 2 1610
一个人的身影
一个人的身影 2020-12-11 21:54

I\'m implementing a C++ expression templates library. I have set up a proper SubMatrixExpr class to collect elements within a matrix, enabling a syntax like

2条回答
  •  甜味超标
    2020-12-11 22:40

    Another idea is to make the types of the arguments in the constructor char *, and then inside the constructor parse out the numbers from the :. For example,

    A = B("3:4","8:end");
    
    A = B(":","2");
    

    This permits you to do more, like use the end keyword.

提交回复
热议问题