Skip to content

Commit

Permalink
clang: fix implicit conversions + add typedef
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Chrétien committed Sep 16, 2015
1 parent ceb6ec9 commit 7435dad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/tnlp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace roboptim
{
using namespace boost;
ROBOPTIM_DEBUG_ONLY
(function_t::size_type n_ = static_cast<function_t::size_type> (n));
(size_type n_ = static_cast<size_type> (n));
assert (costFunction_->inputSize () == n_);
assert (constraintsOutputSize () == m);

Expand Down Expand Up @@ -202,7 +202,7 @@ namespace roboptim

typedef differentiableConstraints_t::const_iterator citer_t;

int constraintId = 0;
size_t constraintId = 0;
for (citer_t it = differentiableConstraints_.begin ();
it != differentiableConstraints_.end (); ++it, constraintId++)
{
Expand Down
3 changes: 2 additions & 1 deletion src/tnlp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ namespace roboptim
public:
typedef T solver_t;
typedef SolverState<typename solver_t::problem_t> solverState_t;
typedef Function::size_type size_type;

Tnlp (const typename solver_t::problem_t& pb, solver_t& solver);

Function::size_type constraintsOutputSize ();
size_type constraintsOutputSize ();

virtual bool
get_nlp_info (Index& n, Index& m, Index& nnz_jac_g,
Expand Down
22 changes: 9 additions & 13 deletions src/tnlp.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,11 @@ namespace roboptim
const DerivableFunction::vector_t& x);

template <typename T>
Function::size_type
computeConstraintsOutputSize (const T& solver)
typename Tnlp<T>::size_type computeConstraintsOutputSize (const T& solver)
{
using namespace boost;

Function::size_type result = 0;
typename Tnlp<T>::size_type result = 0;
typedef typename T::problem_t::constraints_t::const_iterator citer_t;
for (citer_t it = solver.problem ().constraints ().begin ();
it != solver.problem ().constraints ().end (); ++it)
Expand Down Expand Up @@ -147,8 +146,7 @@ namespace roboptim
}

template <typename T>
Function::size_type
Tnlp<T>::constraintsOutputSize ()
typename Tnlp<T>::size_type Tnlp<T>::constraintsOutputSize ()
{
return computeConstraintsOutputSize (solver_);
}
Expand Down Expand Up @@ -253,7 +251,7 @@ namespace roboptim
LinearityType type =
((*it)->template asType<GenericLinearFunction<traits_t> >()) ? TNLP::LINEAR : TNLP::NON_LINEAR;

for (Function::size_type j = 0; j < (*it)->outputSize (); ++j)
for (size_type j = 0; j < (*it)->outputSize (); ++j)
const_types[idx++] = type;
}
return true;
Expand Down Expand Up @@ -351,8 +349,7 @@ namespace roboptim
Index m, Number* g)
{
using namespace boost;
ROBOPTIM_DEBUG_ONLY(typename function_t::size_type n_ =
static_cast<typename function_t::size_type> (n));
ROBOPTIM_DEBUG_ONLY(size_type n_ = static_cast<size_type> (n));

assert ((*costFunction_).inputSize () == n_);
assert (constraintsOutputSize () == m);
Expand All @@ -369,7 +366,7 @@ namespace roboptim

typedef typename constraints_t::const_iterator citer_t;

typename function_t::size_type idx = 0;
size_type idx = 0;
for (citer_t it = constraints_.begin ();
it != constraints_.end (); ++it)
{
Expand Down Expand Up @@ -399,8 +396,7 @@ namespace roboptim
{
using namespace boost;

ROBOPTIM_DEBUG_ONLY(typename function_t::size_type n_ =
static_cast<typename function_t::size_type> (n));
ROBOPTIM_DEBUG_ONLY(size_type n_ = static_cast<size_type> (n));
assert ((*costFunction_).inputSize () == n_);
assert (constraintsOutputSize () == m);

Expand Down Expand Up @@ -442,7 +438,7 @@ namespace roboptim

typedef typename differentiableConstraints_t::const_iterator citer_t;

typename function_t::size_type idx = 0;
size_type idx = 0;
int constraintId = 0;
for (citer_t it = differentiableConstraints_.begin ();
it != differentiableConstraints_.end (); ++it)
Expand Down Expand Up @@ -495,7 +491,7 @@ namespace roboptim
bool, Index ROBOPTIM_DEBUG_ONLY(nele_hess), Index* iRow,
Index* jCol, Number* values)
{
ROBOPTIM_DEBUG_ONLY(function_t::size_type n_ = static_cast<function_t::size_type> (n));
ROBOPTIM_DEBUG_ONLY(size_type n_ = static_cast<size_type> (n));

assert ((*costFunction_).inputSize () == n_);
assert (constraintsOutputSize () == m);
Expand Down

0 comments on commit 7435dad

Please sign in to comment.