Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
[Cpp] Implement operator= for ArraySlice to avoid call to crefIsScalar
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke authored and OpenModelica-Hudson committed Nov 7, 2018
1 parent 648de42 commit 9188bd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenCpp.tpl
Expand Up @@ -11567,7 +11567,7 @@ template equationForLoop(SimEqSystem eq, Context context, Text &varDecls, SimCod
<<
for (int <%iterExp%> = <%startExp%>; <%iterExp%> <= <%endExp%>; <%iterExp%>++) {
<%preExp%>
<%if crefSubIsScalar(cref) then '<%crefPart%> = <%expPart%>' else '<%crefPart%>.assign(<%expPart%>)'%>;
<%crefPart%> = <%expPart%>;
}
>>
end equationForLoop;
Expand Down
12 changes: 12 additions & 0 deletions SimulationRuntime/cpp/Include/Core/Math/ArraySlice.h
Expand Up @@ -305,6 +305,18 @@ class ArraySlice: public ArraySliceConst<T> {
, _baseIdx(ArraySliceConst<T>::_baseIdx) {
}

ArraySlice<T>& operator=(const ArraySlice<T>& b)
{
this->assign(b);
return *this;
}

ArraySlice<T>& operator=(const BaseArray<T>& b)
{
this->assign(b);
return *this;
}

virtual T& operator()(const vector<size_t> &idx) {
return _baseArray(ArraySliceConst<T>::baseIdx(idx.size(), &idx[0]));
}
Expand Down

0 comments on commit 9188bd5

Please sign in to comment.