Skip to content

Commit 7435dad

Browse files
author
Benjamin Chrétien
committed
clang: fix implicit conversions + add typedef
1 parent ceb6ec9 commit 7435dad

3 files changed

Lines changed: 13 additions & 16 deletions

File tree

src/tnlp.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace roboptim
7979
{
8080
using namespace boost;
8181
ROBOPTIM_DEBUG_ONLY
82-
(function_t::size_type n_ = static_cast<function_t::size_type> (n));
82+
(size_type n_ = static_cast<size_type> (n));
8383
assert (costFunction_->inputSize () == n_);
8484
assert (constraintsOutputSize () == m);
8585

@@ -202,7 +202,7 @@ namespace roboptim
202202

203203
typedef differentiableConstraints_t::const_iterator citer_t;
204204

205-
int constraintId = 0;
205+
size_t constraintId = 0;
206206
for (citer_t it = differentiableConstraints_.begin ();
207207
it != differentiableConstraints_.end (); ++it, constraintId++)
208208
{

src/tnlp.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ namespace roboptim
4646
public:
4747
typedef T solver_t;
4848
typedef SolverState<typename solver_t::problem_t> solverState_t;
49+
typedef Function::size_type size_type;
4950

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

52-
Function::size_type constraintsOutputSize ();
53+
size_type constraintsOutputSize ();
5354

5455
virtual bool
5556
get_nlp_info (Index& n, Index& m, Index& nnz_jac_g,

src/tnlp.hxx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,11 @@ namespace roboptim
9191
const DerivableFunction::vector_t& x);
9292

9393
template <typename T>
94-
Function::size_type
95-
computeConstraintsOutputSize (const T& solver)
94+
typename Tnlp<T>::size_type computeConstraintsOutputSize (const T& solver)
9695
{
9796
using namespace boost;
9897

99-
Function::size_type result = 0;
98+
typename Tnlp<T>::size_type result = 0;
10099
typedef typename T::problem_t::constraints_t::const_iterator citer_t;
101100
for (citer_t it = solver.problem ().constraints ().begin ();
102101
it != solver.problem ().constraints ().end (); ++it)
@@ -147,8 +146,7 @@ namespace roboptim
147146
}
148147

149148
template <typename T>
150-
Function::size_type
151-
Tnlp<T>::constraintsOutputSize ()
149+
typename Tnlp<T>::size_type Tnlp<T>::constraintsOutputSize ()
152150
{
153151
return computeConstraintsOutputSize (solver_);
154152
}
@@ -253,7 +251,7 @@ namespace roboptim
253251
LinearityType type =
254252
((*it)->template asType<GenericLinearFunction<traits_t> >()) ? TNLP::LINEAR : TNLP::NON_LINEAR;
255253

256-
for (Function::size_type j = 0; j < (*it)->outputSize (); ++j)
254+
for (size_type j = 0; j < (*it)->outputSize (); ++j)
257255
const_types[idx++] = type;
258256
}
259257
return true;
@@ -351,8 +349,7 @@ namespace roboptim
351349
Index m, Number* g)
352350
{
353351
using namespace boost;
354-
ROBOPTIM_DEBUG_ONLY(typename function_t::size_type n_ =
355-
static_cast<typename function_t::size_type> (n));
352+
ROBOPTIM_DEBUG_ONLY(size_type n_ = static_cast<size_type> (n));
356353

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

370367
typedef typename constraints_t::const_iterator citer_t;
371368

372-
typename function_t::size_type idx = 0;
369+
size_type idx = 0;
373370
for (citer_t it = constraints_.begin ();
374371
it != constraints_.end (); ++it)
375372
{
@@ -399,8 +396,7 @@ namespace roboptim
399396
{
400397
using namespace boost;
401398

402-
ROBOPTIM_DEBUG_ONLY(typename function_t::size_type n_ =
403-
static_cast<typename function_t::size_type> (n));
399+
ROBOPTIM_DEBUG_ONLY(size_type n_ = static_cast<size_type> (n));
404400
assert ((*costFunction_).inputSize () == n_);
405401
assert (constraintsOutputSize () == m);
406402

@@ -442,7 +438,7 @@ namespace roboptim
442438

443439
typedef typename differentiableConstraints_t::const_iterator citer_t;
444440

445-
typename function_t::size_type idx = 0;
441+
size_type idx = 0;
446442
int constraintId = 0;
447443
for (citer_t it = differentiableConstraints_.begin ();
448444
it != differentiableConstraints_.end (); ++it)
@@ -495,7 +491,7 @@ namespace roboptim
495491
bool, Index ROBOPTIM_DEBUG_ONLY(nele_hess), Index* iRow,
496492
Index* jCol, Number* values)
497493
{
498-
ROBOPTIM_DEBUG_ONLY(function_t::size_type n_ = static_cast<function_t::size_type> (n));
494+
ROBOPTIM_DEBUG_ONLY(size_type n_ = static_cast<size_type> (n));
499495

500496
assert ((*costFunction_).inputSize () == n_);
501497
assert (constraintsOutputSize () == m);

0 commit comments

Comments
 (0)