// -*- C++ -*- #ifndef __pack_num_h__ #define __pack_num_h__ #include //#include #include #include #include "base_def.h" namespace MultiArrayHelper { template struct PackNum { template static void makeBlockTypeVec(std::vector >& btv, const std::tuple& ops, std::shared_ptr idxPtr, bool init) { auto subvec = std::move( std::get(ops).block(idxPtr, init) ); btv.insert(btv.end(), subvec.begin(), subvec.end() ); PackNum::makeBlockTypeVec(btv, ops, idxPtr, init); } template static void makeBlockTypeVec(std::vector >& btv, const std::tuple& ops, const IndexInfo* idxPtr, bool init) { auto subvec = std::move( std::get(ops).block(idxPtr, init) ); btv.insert(btv.end(), subvec.begin(), subvec.end() ); PackNum::makeBlockTypeVec(btv, ops, idxPtr, init); } template static void unpackArgs(BlockResult& res, const ArgTuple& tp, const Args&... args) { PackNum::template unpackArgs(res, tp, std::get(tp).get(), args...); } template static void printTuple(std::ostream& out, const std::tuple& tp){ out << std::get(tp) << ", "; PackNum::printTuple(out, tp); } }; template<> struct PackNum<0> { template static void unpackArgs(BlockResult& res, const ArgTuple& tp, const Args&... args) { static_assert(sizeof...(Args) == std::tuple_size::value-1, "inconsistent number of arguments"); BlockBinaryOp(tp).get()), decltype(args)...> f(res); f(std::get<0>(tp).get(), args...); } template static void makeBlockTypeVec(std::vector >& btv, const std::tuple& ops, std::shared_ptr idxPtr, bool init) { auto subvec = std::move( std::get<0>(ops).block(idxPtr, init) ); btv.insert(btv.end(), subvec.begin(), subvec.end() ); } template static void makeBlockTypeVec(std::vector >& btv, const std::tuple& ops, const IndexInfo* idxPtr, bool init) { auto subvec = std::move( std::get<0>(ops).block(idxPtr, init) ); btv.insert(btv.end(), subvec.begin(), subvec.end() ); } template static void printTuple(std::ostream& out, const std::tuple& tp){ out << std::get(tp); } }; } // end namespace MultiArrayHelper #endif