Skip to content

Commit

Permalink
make Cpp code using BOOST_FOREACH work with DynArrayDim1
Browse files Browse the repository at this point in the history
The iterator things are taken over from StatArrayDim1. The second declaration of <%iterName%> with fixed type short is considered a bug.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25448 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
rfranke committed Apr 8, 2015
1 parent 80ecad3 commit d6d55cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenCpp.tpl
Expand Up @@ -14348,7 +14348,7 @@ template algStmtForGeneric_impl(Exp exp, Ident iterator, String type,
<<
<%preExp%>
<%type%> <%iterName%>;
BOOST_FOREACH( short <%iterName%>, <%evar%> ){
BOOST_FOREACH(<%iterName%>, <%evar%>) {
<%body%>
}
>>
Expand Down
20 changes: 17 additions & 3 deletions SimulationRuntime/cpp/Include/Core/Math/Array.h
Expand Up @@ -1341,12 +1341,26 @@ template<typename T>class DynArrayDim1 : public BaseArray<T>
{
return _multi_array.num_elements();
}
virtual size_t getNumDims() const
virtual size_t getNumDims() const
{
return 1;
}
private:
boost::multi_array<T, 1> _multi_array;

typedef typename boost::multi_array<T, 1>::const_iterator const_iterator;
typedef typename boost::multi_array<T, 1>::iterator iterator;

iterator begin()
{
return _multi_array.begin();
}

iterator end()
{
return _multi_array.end();
}

private:
boost::multi_array<T, 1> _multi_array;
};


Expand Down

0 comments on commit d6d55cb

Please sign in to comment.