Design #1242
C++14: Use type auto where appropriate
Description
When we switch to C+11/C++14 consider replacing some explicit type declarations with auto
.
Related issues
History
#1
Updated by John Abbott over 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 newfor
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 forvector<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 newfor
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 :-/
bool3.C
,ApproxPts.C
,ApproxPts2.C
,assert.C
,BigInt.C
nothing to doapply.C
nothing to do (see also #1467)
#11
Updated by John Abbott over 1 year ago
- Target version changed from CoCoALib-0.99850 to CoCoALib-0.99880
#12
Updated by John Abbott 2 months ago
DynamicBitset
uses iterators explicitly; maybe switch toauto
?- possibly review
TmpJB...
code too? LongRange
but see alsostd::ranges
in C++20
#13
Updated by John Abbott 2 months ago
- % Done changed from 10 to 40