Changes between Version 3 and Version 4 of CodingGuidelines
- Timestamp:
- Mar 29, 2012, 10:09:52 AM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CodingGuidelines
v3 v4 1 == How MoleCuilder code should look like == 1 2 ---- 3 [[PageOutline(1-6,,inline)]] 4 ---- 5 6 = Coding Style = #style 7 8 == How MoleCuilder code should look like == #style-file 2 9 3 10 Below you find a brief but hopefully complete list on how the code of espack should look like: … … 31 38 } 32 39 }}} 40 41 = Coding hints = #code 42 43 == Some hints on good code vs. bad code == #code-good-bad 44 45 === end of stream checking === #code--good-bad_eof 46 47 Using 48 {{{ 49 std::inputstream in; 50 while (!in.eof()) { 51 .. 52 } 53 }}} 54 is bad. Rather one should use 55 {{{ 56 std::inputstream in; 57 while (in.getline(...)) { 58 .. 59 } 60 }}} 61 or 62 {{{ 63 std::inputstream in; 64 for(int j; in >> j;;) { 65 .. 66 } 67 }}} 68 or 69 {{{ 70 std::inputstream in; 71 in >> j; 72 if (in.fail()) 73 .. 74 }}} 75 This involves some extra typing but ensures that in case of faulty streams the error is properly pointed at.