commit 8ff6ff3ab034bcc4294f57eba9d8c10e5d16aeee
Author: Akim Demaille <[email protected]>
Date:   Tue Nov 13 06:43:50 2018 +0100

    examples: remove useless includes
    
    * examples/c++/variant-11.yy, examples/c++/variant.yy: here.
    Fix warning when storing a long into an int.

diff --git a/examples/c++/variant-11.yy b/examples/c++/variant-11.yy
index be38589d..31c53ddb 100644
--- a/examples/c++/variant-11.yy
+++ b/examples/c++/variant-11.yy
@@ -37,9 +37,8 @@
 
 %code // *.cc
 {
-#include <algorithm>
+#include <climits>  // INT_MIN, INT_MAX
 #include <iostream>
-#include <iterator>
 #include <sstream>
 
   namespace yy
@@ -141,7 +140,10 @@ int
 main (int argc, const char *argv[])
 {
   if (2 <= argc && isdigit (*argv[1]))
-    max = strtol (argv[1], nullptr, 10);
+    {
+      auto maxl = strtol (argv[1], nullptr, 10);
+      max = INT_MIN <= maxl && maxl <= INT_MAX ? int(maxl) : 4;
+    }
   auto&& p = yy::parser{};
   p.set_debug_level (!!getenv ("YYDEBUG"));
   return p.parse ();
diff --git a/examples/c++/variant.yy b/examples/c++/variant.yy
index 8fba6325..30dd19a4 100644
--- a/examples/c++/variant.yy
+++ b/examples/c++/variant.yy
@@ -33,9 +33,7 @@ typedef std::vector<std::string> strings_type;
 
 %code // *.cc
 {
-#include <algorithm>
 #include <iostream>
-#include <iterator>
 #include <sstream>
 
   namespace yy


Reply via email to