lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 0b00d05 1/4: Use C++17 static inline variable


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 0b00d05 1/4: Use C++17 static inline variable initialization
Date: Mon, 17 Sep 2018 20:48:32 -0400 (EDT)

branch: master
commit 0b00d058da9c560dda326f57c0f86ece40d2080b
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Use C++17 static inline variable initialization
    
    Added a ctor for one class in order to make this work.
---
 ledger_pdf_generator_wx.cpp | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 2810f29..f96af77 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -482,14 +482,20 @@ class html_cell_for_pdf_output : public wxHtmlCell
     class pdf_context
     {
       public:
+        pdf_context()
+            :ledger_           (nullptr)
+            ,writer_           (nullptr)
+            ,interpolate_html_ (nullptr)
+            {}
+
         void set
-            (Ledger const* ledger
-            ,pdf_writer_wx* writer
+            (Ledger            const* ledger
+            ,pdf_writer_wx          * writer
             ,html_interpolator const* interpolate_html
             )
         {
-            ledger_ = ledger;
-            writer_ = writer;
+            ledger_           = ledger;
+            writer_           = writer;
             interpolate_html_ = interpolate_html;
         }
 
@@ -512,9 +518,9 @@ class html_cell_for_pdf_output : public wxHtmlCell
         }
 
       private:
-        Ledger const* ledger_ = nullptr;
-        pdf_writer_wx* writer_ = nullptr;
-        html_interpolator const* interpolate_html_ = nullptr;
+        Ledger            const* ledger_;
+        pdf_writer_wx          * writer_;
+        html_interpolator const* interpolate_html_;
     };
 
     // Small helper to check that we're using the expected DC and, also, acting
@@ -537,14 +543,11 @@ class html_cell_for_pdf_output : public wxHtmlCell
         LMI_ASSERT(&dc == &pdf_context_for_html_output.writer().dc());
     }
 
-    static pdf_context pdf_context_for_html_output;
+    static inline pdf_context pdf_context_for_html_output = {};
 
     friend pdf_context_setter;
 };
 
-html_cell_for_pdf_output::pdf_context
-html_cell_for_pdf_output::pdf_context_for_html_output;
-
 // Define scaffolding for a custom HTML "img" tag which must be used
 // instead of the standard one in order to allow specifying the scaling factor
 // that we want to use for the image in the PDF. Unfortunately this can't be
@@ -1212,14 +1215,12 @@ class numbered_page : public page_with_footer
         return oss.str();
     }
 
-    static int last_page_number_;
-    int        this_page_number_     = 0;
-    int        extra_pages_          = 0;
+    // "-1" is invalid; use start_numbering() to change it.
+    static inline int last_page_number_ = {-1};
+    int               this_page_number_ = {0};
+    int               extra_pages_      = {0};
 };
 
-// Initial value is invalid, use start_numbering() to change it.
-int numbered_page::last_page_number_ = -1;
-
 // Simplest possible page which is entirely defined by its external template
 // whose name must be specified when constructing it.
 class standard_page : public numbered_page



reply via email to

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