emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/beardbolt 10fe7307c3 291/323: Get a better C++ starter


From: ELPA Syncer
Subject: [elpa] externals/beardbolt 10fe7307c3 291/323: Get a better C++ starter example
Date: Thu, 9 Mar 2023 10:58:45 -0500 (EST)

branch: externals/beardbolt
commit 10fe7307c3b25ffa15fd28f459c691032f85032f
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Get a better C++ starter example
---
 starters/beardbolt.cpp | 43 ++++++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/starters/beardbolt.cpp b/starters/beardbolt.cpp
index 0c425d90c1..30582dc150 100644
--- a/starters/beardbolt.cpp
+++ b/starters/beardbolt.cpp
@@ -1,29 +1,26 @@
 #include <iostream>
+#include <array>
+#include <vector>
+#include <span>
 
-// C++ beardbolt starter file
-
-// Local Variables:
-// beardbolt-command: "g++ -O3"
-// rmsbolt-command: "g++ -O3"
-// beardbolt-kill-symbol-re: "\\(^_Z[^0-9]*[SP]\\|__gnu\\)"
-// beardbolt-disassemble: nil
-// End:
-
-int isRMS(int a) {
-  switch (a) {
-  case 'R':
-    return 1;
-  case 'M':
-    return 2;
-  case 'S':
-    return 3;
-  default:
-    return 0;
-  }
+template <typename F, typename T >
+void bubble(F from, T to) {
+  for (auto i = from; i < to - 1; i++)
+    for (auto j = to - 1; i < j; j--)
+      if (*j < *(j - 1))
+        std::swap(*j, *(j - 1));
 }
 
 int main() {
-  char a = 1 + 1;
-  if (isRMS(a))
-    std::cout << a << std::endl;
+  std::array a{5, 2, 1, 4, 2};
+  bubble(a.begin(), a.end());
+
+  std::cout << " Sorted array : ";
+  for (const auto& e : a) std::cout << e << "\n";
+  return 0;
 }
+
+// Local Variables:
+// beardbolt-command: "g++ -std=c++20 -O3"
+// beardbolt-kill-symbol-re: "\\(^_Z[^0-9]*[SP]\\|__\\)"
+// End:



reply via email to

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