Project

General

Profile

Design #1242

C++14: Use type auto where appropriate

Added by John Abbott about 5 years ago. Updated 5 days ago.

Status:
In Progress
Priority:
Normal
Assignee:
-
Category:
Tidying
Target version:
Start date:
08 Feb 2019
Due date:
% Done:

40%

Estimated time:
Spent time:

Description

When we switch to C+11/C++14 consider replacing some explicit type declarations with auto.


Related issues

Related to CoCoALib - Feature #82: C++11 compatibility questionsClosed2012-01-26

Related to CoCoALib - Design #1225: Move to C++14 (skipping C++11)In Progress2018-09-06

Related to CoCoALib - Design #1346: C++14: use the new for loop syntax where appropriate (like cocoa's foreach)In Progress2019-10-21

History

#1 Updated by John Abbott about 5 years ago

  • Related to Feature #82: C++11 compatibility questions added

#2 Updated by John Abbott over 4 years ago

  • Related to Design #1225: Move to C++14 (skipping C++11) added

#3 Updated by John Abbott over 4 years ago

I must re-read the relevant parts of Meyers's book (Eff. Modern C++). Where should we use auto?
  • use auto instead of the explicit type for C++ iterators (usu. the explicit type is "unreadable"); but see also Meyers's notes about the new for loop syntax
  • I suggest not using auto if the explicit type is "simple and easy to read" (e.g. I think I would not use it for vector<RingElem>).
  • overall guideline: we should use auto to help make the code easier to read and understand

#4 Updated by John Abbott over 4 years ago

It may be helpful to keep a list of source files which have been "done" (this may also include that the file was looked at, but in the end we decided not to use auto anywhere)
  • SparsePolyOps-ideal-ZeroDim.C (for const iterator in for loops)
  • SparsePolyOps-ideal-monomial.C (for const iterator in for loops)

NOTE: I expect that we would use auto only very rarely in header files...

#5 Updated by Anna Maria Bigatti over 4 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

#6 Updated by Anna Maria Bigatti over 4 years ago

John Abbott wrote:

  • use auto instead of the explicit type for C++ iterators (usu. the explicit type is "unreadable"); but see also Meyers's notes about the new for loop syntax

I have tried the new for loop syntax in SparsePolyOps-ideal-monomial.C.
It's like a dream come true :-)

#7 Updated by John Abbott over 4 years ago

  • Related to Design #1346: C++14: use the new for loop syntax where appropriate (like cocoa's foreach) added

#8 Updated by John Abbott over 4 years ago

I have created a new issue (#1346) about using the new for loop syntax; please put relevant progress reports there :-)

#9 Updated by John Abbott over 4 years ago

  • Target version changed from CoCoALib-0.99700 to CoCoALib-0.99800

#10 Updated by John Abbott over 3 years ago

  • Target version changed from CoCoALib-0.99800 to CoCoALib-0.99850

I suggest we work through the source file systematically, and note which ones we have updated to use auto (and which are still to do).
This will be a long task :-/

Source files which have already been done:
  • bool3.C, ApproxPts.C, ApproxPts2.C, assert.C, BigInt.C nothing to do
  • apply.C nothing to do (see also #1467)

#11 Updated by John Abbott about 1 year ago

  • Target version changed from CoCoALib-0.99850 to CoCoALib-0.99880

#12 Updated by John Abbott 5 days ago

  • DynamicBitset uses iterators explicitly; maybe switch to auto?
  • possibly review TmpJB... code too?
  • LongRange but see also std::ranges in C++20

#13 Updated by John Abbott 5 days ago

  • % Done changed from 10 to 40

Also available in: Atom PDF