lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master d71f9e8 02/12: Improve parameter names


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d71f9e8 02/12: Improve parameter names
Date: Sat, 24 Oct 2020 16:51:33 -0400 (EDT)

branch: master
commit d71f9e8fda2044e9c9aa1068a9e7a5c093c904fd
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Improve parameter names
    
    The use of 'T' as the element type of std::vector is such widespread
    practice that using 'T' as a typedef for a vector of some type is
    confusing.
---
 xml_serialize.hpp | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/xml_serialize.hpp b/xml_serialize.hpp
index bd80024..047a64d 100644
--- a/xml_serialize.hpp
+++ b/xml_serialize.hpp
@@ -78,36 +78,36 @@ struct xml_io
 /// (and non-element nodes) that might have been added manually,
 /// e.g., as documentation.
 ///
-/// C++11 has no way to assert that T is a Sequence; for the nonce,
+/// C++11 has no way to assert that C is a Sequence; for the nonce,
 /// no other Sequence being used, assert that it's a vector.
 
-template<typename T>
+template<typename C>
 struct xml_sequence_io
 {
-    typedef typename T::value_type item_t;
-    static_assert(std::is_same<T,std::vector<item_t>>::value);
+    using T = typename C::value_type;
+    static_assert(std::is_same<C,std::vector<T>>::value);
 
-    static void to_xml(xml::element& e, T const& t)
+    static void to_xml(xml::element& e, C const& c)
     {
         e.clear();
-        for(auto const& i : t)
+        for(auto const& i : c)
             {
             // This is not equivalent to calling set_element():
             // multiple <item> elements are expressly permitted.
             xml::element z("item");
-            xml_io<item_t>::to_xml(z, i);
+            xml_io<T>::to_xml(z, i);
             e.push_back(z);
             }
     }
 
-    static void from_xml(xml::element const& e, T& t)
+    static void from_xml(xml::element const& e, C& c)
     {
-        t.clear();
+        c.clear();
         for(auto const& i : e.elements("item"))
             {
-            item_t z;
-            xml_io<item_t>::from_xml(i, z);
-            t.push_back(z);
+            T z;
+            xml_io<T>::from_xml(i, z);
+            c.push_back(z);
             }
     }
 };



reply via email to

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