Fix a lot of ref issues reagrding extarction, rvalueness and proper use of temporary memory.
This commit is contained in:
parent
d5c41bf43e
commit
379d77ebef
50 changed files with 2945 additions and 1397 deletions
|
|
@ -31,8 +31,8 @@ namespace rotgen
|
|||
auto extract(Entity& e, Index i0, Index j0, Index ni, Index nj)
|
||||
{
|
||||
detail::validate_extract(e, i0, j0, ni, nj);
|
||||
if constexpr (concepts::reference<Entity>)
|
||||
return extract(e.base(), i0, j0, ni, nj);
|
||||
if constexpr (requires { e.as_map(); })
|
||||
return extract(e.as_map(), i0, j0, ni, nj);
|
||||
else return block<detail::propagate_const<Entity>>(e, i0, j0, ni, nj);
|
||||
}
|
||||
|
||||
|
|
@ -41,8 +41,8 @@ namespace rotgen
|
|||
auto extract(Entity& e, Index i0, Index j0)
|
||||
{
|
||||
detail::validate_extract(e, i0, j0, NI, NJ);
|
||||
if constexpr (concepts::reference<Entity>)
|
||||
return extract<NI, NJ>(e.base(), i0, j0);
|
||||
if constexpr (requires { e.as_map(); })
|
||||
return extract<NI, NJ>(e.as_map(), i0, j0);
|
||||
else return block<detail::propagate_const<Entity>, NI, NJ>(e, i0, j0);
|
||||
}
|
||||
|
||||
|
|
@ -51,8 +51,8 @@ namespace rotgen
|
|||
auto extract(Entity& e, Index i0, Index j0, Index ni, Index nj)
|
||||
{
|
||||
detail::validate_extract(e, i0, j0, ni, nj);
|
||||
if constexpr (concepts::reference<Entity>)
|
||||
return extract<NI, NJ>(e.base(), i0, j0, ni, nj);
|
||||
if constexpr (requires { e.as_map(); })
|
||||
return extract<NI, NJ>(e.as_map(), i0, j0, ni, nj);
|
||||
else
|
||||
return block<detail::propagate_const<Entity>, NI, NJ>(e, i0, j0, ni, nj);
|
||||
}
|
||||
|
|
@ -112,83 +112,116 @@ namespace rotgen
|
|||
//======================== TOP ROWS ========================
|
||||
template<concepts::entity Entity> auto topRows(Entity& e, Index ni)
|
||||
{
|
||||
return extract(e, 0, 0, ni, e.cols());
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract(e, 0, 0, ni, e.cols());
|
||||
else return extract<-1, Entity::ColsAtCompileTime>(e, 0, 0, ni, e.cols());
|
||||
}
|
||||
|
||||
template<Index NI, concepts::entity Entity> auto topRows(Entity& e)
|
||||
{
|
||||
return extract<NI, -1>(e, 0, 0, NI, e.cols());
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract<NI, -1>(e, 0, 0, NI, e.cols());
|
||||
else return extract<NI, Entity::ColsAtCompileTime>(e, 0, 0);
|
||||
}
|
||||
|
||||
//======================== MIDDLE ROWS ========================
|
||||
template<concepts::entity Entity>
|
||||
auto middleRows(Entity& e, Index i0, Index ni)
|
||||
{
|
||||
return extract(e, i0, 0, ni, e.cols());
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract(e, i0, 0, ni, e.cols());
|
||||
else return extract<-1, Entity::ColsAtCompileTime>(e, i0, 0, ni, e.cols());
|
||||
}
|
||||
|
||||
template<Index NI, concepts::entity Entity>
|
||||
auto middleRows(Entity& e, Index i0)
|
||||
{
|
||||
return extract<NI, -1>(e, i0, 0, NI, e.cols());
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract<NI, -1>(e, i0, 0, NI, e.cols());
|
||||
else return extract<NI, Entity::ColsAtCompileTime>(e, i0, 0);
|
||||
}
|
||||
|
||||
//======================== BOTTOM ROWS ========================
|
||||
template<concepts::entity Entity> auto bottomRows(Entity& e, Index ni)
|
||||
{
|
||||
return extract(e, e.rows() - ni, 0, ni, e.cols());
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract(e, e.rows() - ni, 0, ni, e.cols());
|
||||
else
|
||||
return extract<-1, Entity::ColsAtCompileTime>(e, e.rows() - ni, 0, ni,
|
||||
e.cols());
|
||||
}
|
||||
|
||||
template<Index NI, concepts::entity Entity> auto bottomRows(Entity& e)
|
||||
{
|
||||
return extract<NI, -1>(e, e.rows() - NI, 0, NI, e.cols());
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract<NI, -1>(e, e.rows() - NI, 0, NI, e.cols());
|
||||
else return extract<NI, Entity::ColsAtCompileTime>(e, e.rows() - NI, 0);
|
||||
}
|
||||
|
||||
//======================== LEFT COLS ========================
|
||||
template<concepts::entity Entity> auto leftCols(Entity& e, Index nj)
|
||||
{
|
||||
return extract(e, 0, 0, e.rows(), nj);
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract(e, 0, 0, e.rows(), nj);
|
||||
else return extract<Entity::RowsAtCompileTime, -1>(e, 0, 0, e.rows(), nj);
|
||||
}
|
||||
|
||||
template<Index NJ, concepts::entity Entity> auto leftCols(Entity& e)
|
||||
{
|
||||
return extract<-1, NJ>(e, 0, 0, e.rows(), NJ);
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract<-1, NJ>(e, 0, 0, e.rows(), NJ);
|
||||
else return extract<Entity::RowsAtCompileTime, NJ>(e, 0, 0);
|
||||
}
|
||||
|
||||
//======================== MIDDLE COLS ========================
|
||||
template<concepts::entity Entity>
|
||||
auto middleCols(Entity& e, Index j0, Index nj)
|
||||
{
|
||||
return extract(e, 0, j0, e.rows(), nj);
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract(e, 0, j0, e.rows(), nj);
|
||||
else return extract<Entity::RowsAtCompileTime, -1>(e, 0, j0, e.rows(), nj);
|
||||
}
|
||||
|
||||
template<Index NJ, concepts::entity Entity>
|
||||
auto middleCols(Entity& e, Index j0)
|
||||
{
|
||||
return extract<-1, NJ>(e, 0, j0, e.rows(), NJ);
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract<-1, NJ>(e, 0, j0, e.rows(), NJ);
|
||||
else return extract<Entity::RowsAtCompileTime, NJ>(e, 0, j0);
|
||||
}
|
||||
|
||||
//======================== RIGHT COLS ========================
|
||||
template<concepts::entity Entity> auto rightCols(Entity& e, Index nj)
|
||||
{
|
||||
return extract(e, 0, e.cols() - nj, e.rows(), nj);
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract(e, 0, e.cols() - nj, e.rows(), nj);
|
||||
else
|
||||
return extract<Entity::RowsAtCompileTime, -1>(e, 0, e.cols() - nj,
|
||||
e.rows(), nj);
|
||||
;
|
||||
}
|
||||
|
||||
template<Index NJ, concepts::entity Entity> auto rightCols(Entity& e)
|
||||
{
|
||||
return extract<-1, NJ>(e, 0, e.cols() - NJ, e.rows(), NJ);
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract<-1, NJ>(e, 0, e.cols() - NJ, e.rows(), NJ);
|
||||
else return extract<Entity::RowsAtCompileTime, NJ>(e, 0, e.cols() - NJ);
|
||||
}
|
||||
|
||||
//======================== ROW ========================
|
||||
template<concepts::entity Entity> auto row(Entity& e, Index i0)
|
||||
{
|
||||
return extract<1, -1>(e, i0, 0, 1, e.cols());
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract<1, -1>(e, i0, 0, 1, e.cols());
|
||||
else return extract<1, Entity::ColsAtCompileTime>(e, i0, 0);
|
||||
}
|
||||
|
||||
//======================== COL ========================
|
||||
template<concepts::entity Entity> auto col(Entity& e, Index j0)
|
||||
{
|
||||
return extract<-1, 1>(e, 0, j0, e.rows(), 1);
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract<-1, 1>(e, 0, j0, e.rows(), 1);
|
||||
else return extract<Entity::RowsAtCompileTime, 1>(e, 0, j0);
|
||||
}
|
||||
|
||||
//======================== VECTOR HEAD ========================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue