[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);
}
}
};
- [lmi-commits] [lmi] master updated (61277aa -> 4427d76), Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 65f92f3 06/12: Refactor, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 75399fe 01/12: Improve documentation, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master be4c0fd 05/12: Rename 'mete_*' functions for concinnity, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master d71f9e8 02/12: Improve parameter names,
Greg Chicares <=
- [lmi-commits] [lmi] master 9671a72 03/12: Rearrange for concinnity, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 195d544 07/12: Improve explanation of certain unit tests, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master fdb2a62 04/12: Clarify unit-test output, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 75cf29b 08/12: Rename local variables, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master fb65723 09/12: Serialize pairs to and from xml, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master d385546 10/12: Serialize associative-pair containers to and from xml, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 2ba9033 11/12: Improve a variable's name, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 4427d76 12/12: C++17-ize, Greg Chicares, 2020/10/24