[bug #53280] Eliminate C++0X workarounds now that C++11 is required
"Dmitri A. Sergatskov" <[email protected]>
| Newsgroups | gmane.comp.gnu.octave.bugs |
|---|---|
| Message-ID | <[email protected]> |
Please use the bug tracker to post updates to a bug report. The mailing list is intended as a read-only notification stream. Info posted to this mailing list address won't appear in the tracker database where it is most useful.
Follow-up Comment #6, bug #53280 (group octave):
For call-stack I think this is modern way:
diff -r 1f53dcedea5b libinterp/corefcn/call-stack.cc
--- a/libinterp/corefcn/call-stack.cc Sun Feb 15 16:14:32 2026 +0100
+++ b/libinterp/corefcn/call-stack.cc Sun Feb 15 12:20:02 2026 -0500
@@ -49,12 +49,7 @@
OCTAVE_BEGIN_NAMESPACE(octave)
-// Use static fields for the best efficiency.
-// NOTE: C++0x will allow these two to be merged into one.
-static const char *bt_fieldnames[] =
-{ "file", "name", "line", "column", nullptr };
-
-static const octave_fields bt_fields (bt_fieldnames);
+static const octave_fields bt_fields {"file", "name", "line", "column"};
call_stack::call_stack (tree_evaluator& evaluator)
: m_evaluator (evaluator), m_cs (), m_curr_frame (0),
diff -r 1f53dcedea5b libinterp/corefcn/oct-map.cc
--- a/libinterp/corefcn/oct-map.cc Sun Feb 15 16:14:32 2026 +0100
+++ b/libinterp/corefcn/oct-map.cc Sun Feb 15 12:20:02 2026 -0500
@@ -58,6 +58,22 @@
(*m_rep)[std::string (*fields++)] = n++;
}
+octave_fields::octave_fields (std::initializer_list<std::string_view> names)
+ : m_rep (new fields_rep ())
+{
+ octave_idx_type n = 0;
+
+ for (std::string_view sv : names)
+ {
+ if (sv.empty ())
+ continue;
+
+ auto ret = m_rep->emplace (std::string (sv), n);
+ if (ret.second)
+ n++;
+ }
+}
+
bool
octave_fields::isfield (const std::string& field) const
{
diff -r 1f53dcedea5b libinterp/corefcn/oct-map.h
--- a/libinterp/corefcn/oct-map.h Sun Feb 15 16:14:32 2026 +0100
+++ b/libinterp/corefcn/oct-map.h Sun Feb 15 12:20:02 2026 -0500
@@ -29,7 +29,9 @@
#include "octave-config.h"
#include <algorithm>
+#include <initializer_list>
#include <map>
+#include <string_view>
#include "oct-refcount.h"
@@ -67,6 +69,7 @@
octave_fields () : m_rep (nil_rep ()) { m_rep->m_count++; }
octave_fields (const string_vector&);
octave_fields (const char *const *);
+ octave_fields (std::initializer_list<std::string_view>);
~octave_fields ()
{
Also attached (file call-stack_cxx17.diff)
Dmitri.
--
(file #58248)
_______________________________________________________
Additional Item Attachment:
Name: call-stack_cxx17.diff Size: 1.9KiB
<https://file.savannah.gnu.org/file/call-stack_cxx17.diff?file_id=58248>
AGPL NOTICE
These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://savannah.gnu.org/source/savane-9953bb12daa795c366b6ab4c67b1c25dc9ff6156.tar.gz
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?53280>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaZIDcQAKCRCqLAuaBUf3 TmNaAP9WrvWCFxSFH73147jLTRjxWVL2fQp1Cbv8yzC3rhtvmQD/fpGAaLoAuUWa XWfV3agAPv3gfH+nkDN1E8ASG4NPrQA= =+w3S -----END PGP SIGNATURE-----