Template trick to optimize out allocations

前端 未结 3 728
南旧
南旧 2021-02-03 11:20

I have:

struct DoubleVec {
  std::vector data;
};

DoubleVec operator+(const DoubleVec& lhs, const DoubleVec& rhs) {
  DoubleVec ans(lhs.si         


        
3条回答
  •  甜味超标
    2021-02-03 11:37

    Have a look at Boost.Proto, which is a library for writing EDSL (embedded domain specific languages) directly in C++. There is even an example showing exactly what you need.

提交回复
热议问题