[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1930b4b 1/4: Write friend declarations at the
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1930b4b 1/4: Write friend declarations at the top of class declarations |
Date: |
Wed, 26 Sep 2018 19:35:13 -0400 (EDT) |
branch: master
commit 1930b4b0cf494341e3a3b571085ecf29002a2488
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Write friend declarations at the top of class declarations
Moved friend declarations to the top of class declarations, before
anything else except static assertions. Concinnity requires uniformity;
placement at the top makes friend declarations more prominent.
Incidentally, also for concinnity, wrote elaborated-type-specifiers
whenever befriending classes. This seems to be the best uniform rule:
it's more explicit, hence easier to read; and it requires no forward
declaration--see the example in C++17 (N4659) [14.3/3]:
class X2 {
friend Ct; // OK: class C is a friend
friend D; // error: no type-name D in scope
friend class D; // OK: elaborated-type-specifier declares new class
};
---
input_sequence_entry.cpp | 4 ++--
ledger_evaluator.hpp | 4 ++--
ledger_pdf_generator_wx.cpp | 4 ++--
product_data.hpp | 4 ++--
rate_table.hpp | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 6220f81..0284958 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -183,6 +183,8 @@ bool DurationModeChoice::needs_number() const
class InputSequenceEditor
:public wxDialog
{
+ friend class LayoutOnceGuard;
+
public:
InputSequenceEditor(wxWindow* parent, wxString const& title, Input const&
input);
InputSequenceEditor(InputSequenceEditor const&) = delete;
@@ -242,8 +244,6 @@ class InputSequenceEditor
InputSequenceEditor* const editor_;
};
- friend class LayoutOnceGuard;
-
// If this is positive, layout is frozen and needs to wait until it's
// thawed which will happen when all currently existing LayoutOnceGuards go
// out of scope.
diff --git a/ledger_evaluator.hpp b/ledger_evaluator.hpp
index cb1d282..d5ef54b 100644
--- a/ledger_evaluator.hpp
+++ b/ledger_evaluator.hpp
@@ -36,6 +36,8 @@
class LMI_SO ledger_evaluator
{
+ friend class Ledger;
+
public:
std::string operator()(std::string const& scalar) const;
std::string operator()(std::string const& vector, std::size_t index) const;
@@ -53,8 +55,6 @@ class LMI_SO ledger_evaluator
all_scalars const scalars_;
all_vectors const vectors_;
-
- friend class Ledger;
};
#endif // ledger_evaluator_hpp
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index ad85406..aa6c47b 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -479,6 +479,8 @@ TAG_HANDLER_END(page_header)
// generate it.
class html_cell_for_pdf_output : public wxHtmlCell
{
+ friend class pdf_context_setter;
+
public:
// Before using this class a pdf_context_setter object needs to be
// instantiated (and remain alive for as long as this class is used).
@@ -583,8 +585,6 @@ class html_cell_for_pdf_output : public wxHtmlCell
}
static inline pdf_context pdf_context_for_html_output = {};
-
- friend pdf_context_setter;
};
// Define scaffolding for a custom HTML "img" tag which must be used
diff --git a/product_data.hpp b/product_data.hpp
index e8ecbaa..605ef06 100644
--- a/product_data.hpp
+++ b/product_data.hpp
@@ -80,10 +80,10 @@ class LMI_SO product_data final
:public xml_serializable <product_data>
,public MemberSymbolTable <product_data>
{
- typedef deserialized<product_data>::value_type value_type;
-
friend class PolicyDocument;
+ typedef deserialized<product_data>::value_type value_type;
+
public:
explicit product_data(std::string const& product_name);
~product_data() override;
diff --git a/rate_table.hpp b/rate_table.hpp
index 030c9b5..d87afae 100644
--- a/rate_table.hpp
+++ b/rate_table.hpp
@@ -51,6 +51,8 @@ class database_impl;
/// This class has value semantics.
class table
{
+ friend class database_impl;
+
public:
// table number: just an integer wrapped in a class for type-safety.
class Number
@@ -99,8 +101,6 @@ class table
}
std::shared_ptr<table_impl> impl_;
-
- friend database_impl;
};
/// A database in SOA binary format.