lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [PATCH] C++ m11n: range-based for loops


From: Greg Chicares
Subject: Re: [lmi] [PATCH] C++ m11n: range-based for loops
Date: Wed, 18 Jan 2017 10:01:10 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 2017-01-16 15:43, Greg Chicares wrote:
> On 2017-01-15 17:59, Greg Chicares wrote:
> [...]
>> And here's a freshly-annotated update to the plan I posted earlier,
>> reflecting the changes I pushed a few minutes ago.
> 
> I pushed some more changes; here's a further update.

I just pushed an update to 'test_coding_rules.cpp' that enforces our
agreed style for range-based for loops.

To test regexes, it is very handy to paste them between the "//" here:

$perl -ne 'print if //' some_test_file 2>&1 |less

and then back into the C++ code (the round trip works now that we're
using raw literals).

It is rather annoying to write "[^\n]" instead of "." for the reasons
described here, beginning at line 110:

http://git.savannah.gnu.org/cgit/lmi.git/tree/regex_test.cpp?id=85a089ef8d0e096eea2fa0a821f14c0cc4f058a8

AFAICS, std::regex doesn't have boost's match_not_dot_newline in its
match_flag_type; and, while its syntax_option_type has "multiline"
as of C++17, that affects '^$' anchors, not '.'. Maybe I should just
write regexes with "." and implement a function to convert it to
"[^\n]", someday.

Anyway, with this temporary change:

---------8<--------8<--------8<--------8<--------8<--------8<--------8<-------
--- ../test_coding_rules.cpp    2017-01-18 08:53:51.747291787 +0000
+++ test_coding_rules.cpp       2017-01-18 09:02:52.620362510 +0000
@@ -612,6 +612,31 @@
                 }
             }
         }
+// Temporary built-in unit test:
+#if 0
+    for instance (i.e.: e.g. (in Latin))
+
+    for( auto const  f0: fff);
+    for( auto const  f1 : fff);
+    for( auto const& f2 :fff);
+    for( auto const& f3: fff);
+    for( auto        f4 : fff);
+    for( auto        f5 :fff);
+    for( auto &      f6:fff);
+    for( auto &      fX : fff);
+    for( auto&       fY : fff); // okay
+    for( auto const& fZ : fff); // okay
+
+    for(auto const& gA : ggg); // okay
+    for(auto&       gB : ggg); // okay
+    for(char const& g0 : ggg);
+    for(char &      g1 : ggg);
+    for(char&       g2 : ggg);
+    for(char        g3 : ggg);
+    for(foo::bar &  g4 :ggg);
+    for(foo::bar&   g5 :ggg);
+    for(foo::bar    g6 :ggg);
+#endif // 0
     }
 }
 
--------->8-------->8-------->8-------->8-------->8-------->8-------->8-------

it prints:

File 'test_coding_rules.cpp' spurious or malformed for-range-declaration: 'for 
instance (i.e.: e.g. (in Latin)'.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'auto const'.
File 'test_coding_rules.cpp' should have a space on both sides of the colon 
following the for-range-declaration, instead of ': '.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'auto const'.
File 'test_coding_rules.cpp' should have a space on both sides of the colon 
following the for-range-declaration, instead of ' :'.
File 'test_coding_rules.cpp' should have a space on both sides of the colon 
following the for-range-declaration, instead of ': '.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'auto        f'.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'auto        f'.
File 'test_coding_rules.cpp' should have a space on both sides of the colon 
following the for-range-declaration, instead of ' :'.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'auto &'.
File 'test_coding_rules.cpp' should have a space on both sides of the colon 
following the for-range-declaration, instead of ':'.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'auto &'.
File 'test_coding_rules.cpp' for-range-declaration should deduce type rather 
than specify 'char'.
File 'test_coding_rules.cpp' for-range-declaration should deduce type rather 
than specify 'char'.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'char &'.
File 'test_coding_rules.cpp' for-range-declaration should deduce type rather 
than specify 'char'.
File 'test_coding_rules.cpp' for-range-declaration should deduce type rather 
than specify 'char'.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'char        g'.
File 'test_coding_rules.cpp' for-range-declaration should deduce type rather 
than specify 'foo::bar'.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'foo::bar &'.
File 'test_coding_rules.cpp' should have a space on both sides of the colon 
following the for-range-declaration, instead of ' :'.
File 'test_coding_rules.cpp' for-range-declaration should deduce type rather 
than specify 'foo::bar'.
File 'test_coding_rules.cpp' should have a space on both sides of the colon 
following the for-range-declaration, instead of ' :'.
File 'test_coding_rules.cpp' for-range-declaration should deduce type rather 
than specify 'foo::bar'.
File 'test_coding_rules.cpp' for-range-declaration should use 'auto&' or 'auto 
const&' instead of 'foo::bar    g'.
File 'test_coding_rules.cpp' should have a space on both sides of the colon 
following the for-range-declaration, instead of ' :'.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]