From 28b7d27943bb1c8d205cb1d37cee0633ff1fef8e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 24 Apr 2017 18:33:02 -0400 Subject: [PATCH] include/encoding: use more auto Signed-off-by: Sage Weil --- src/include/encoding.h | 51 ++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/src/include/encoding.h b/src/include/encoding.h index 9ea25d316d1..2c210a42cc5 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -389,7 +389,7 @@ inline typename std::enable_if::type { __u32 n = (__u32)(ls.size()); // c++11 std::list::size() is O(1) encode(n, bl); - for (typename std::list::const_iterator p = ls.begin(); p != ls.end(); ++p) + for (auto p = ls.begin(); p != ls.end(); ++p) encode(*p, bl); } template> @@ -401,7 +401,7 @@ inline typename std::enable_if::type unsigned pos = bl.length(); unsigned n = 0; encode(n, bl); - for (typename std::list::const_iterator p = ls.begin(); p != ls.end(); ++p) { + for (auto p = ls.begin(); p != ls.end(); ++p) { n++; encode(*p, bl, features); } @@ -411,7 +411,7 @@ inline typename std::enable_if::type } else { __u32 n = (__u32)(ls.size()); // FIXME: this is slow on a list. encode(n, bl); - for (typename std::list::const_iterator p = ls.begin(); p != ls.end(); ++p) + for (auto p = ls.begin(); p != ls.end(); ++p) encode(*p, bl, features); } } @@ -436,7 +436,7 @@ inline void encode(const std::list, Alloc>& ls, { __u32 n = (__u32)(ls.size()); // c++11 std::list::size() is O(1) encode(n, bl); - for (typename std::list >::const_iterator p = ls.begin(); p != ls.end(); ++p) + for (auto p = ls.begin(); p != ls.end(); ++p) encode(**p, bl); } template @@ -445,7 +445,7 @@ inline void encode(const std::list, Alloc>& ls, { __u32 n = (__u32)(ls.size()); // c++11 std::list::size() is O(1) encode(n, bl); - for (typename std::list >::const_iterator p = ls.begin(); p != ls.end(); ++p) + for (auto p = ls.begin(); p != ls.end(); ++p) encode(**p, bl, features); } template @@ -469,7 +469,7 @@ inline typename std::enable_if::type { __u32 n = (__u32)(s.size()); encode(n, bl); - for (typename std::set::const_iterator p = s.begin(); p != s.end(); ++p) + for (auto p = s.begin(); p != s.end(); ++p) encode(*p, bl); } template> @@ -490,7 +490,7 @@ template> inline typename std::enable_if::type encode_nohead(const std::set& s, bufferlist& bl) { - for (typename std::set::const_iterator p = s.begin(); p != s.end(); ++p) + for (auto p = s.begin(); p != s.end(); ++p) encode(*p, bl); } template> @@ -554,7 +554,7 @@ inline void encode(const std::multiset& s, bufferlist& bl) { __u32 n = (__u32)(s.size()); encode(n, bl); - for (typename std::multiset::const_iterator p = s.begin(); p != s.end(); ++p) + for (auto p = s.begin(); p != s.end(); ++p) encode(*p, bl); } template @@ -623,7 +623,7 @@ template> inline typename std::enable_if::type encode_nohead(const std::vector& v, bufferlist& bl) { - for (typename std::vector::const_iterator p = v.begin(); p != v.end(); ++p) + for (auto p = v.begin(); p != v.end(); ++p) encode(*p, bl); } template> @@ -643,7 +643,7 @@ inline void encode(const std::vector,Alloc>& v, { __u32 n = (__u32)(v.size()); encode(n, bl); - for (typename std::vector >::const_iterator p = v.begin(); p != v.end(); ++p) + for (auto p = v.begin(); p != v.end(); ++p) if (*p) encode(**p, bl, features); else @@ -655,7 +655,7 @@ inline void encode(const std::vector,Alloc>& v, { __u32 n = (__u32)(v.size()); encode(n, bl); - for (typename std::vector >::const_iterator p = v.begin(); p != v.end(); ++p) + for (auto p = v.begin(); p != v.end(); ++p) if (*p) encode(**p, bl); else @@ -708,7 +708,7 @@ inline typename std::enable_if::const_iterator p = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl); encode(p->second, bl); } @@ -721,7 +721,7 @@ inline typename std::enable_if::const_iterator p = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl, features); encode(p->second, bl, features); } @@ -758,7 +758,7 @@ inline typename std::enable_if::type encode_nohead(const std::map& m, bufferlist& bl) { - for (typename std::map::const_iterator p = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl); encode(p->second, bl); } @@ -769,7 +769,7 @@ inline typename std::enable_if::type encode_nohead(const std::map& m, bufferlist& bl, uint64_t features) { - for (typename std::map::const_iterator p = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl, features); encode(p->second, bl, features); } @@ -812,8 +812,7 @@ template::const_iterator p - = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl, features); encode(p->second, bl, features); } @@ -852,8 +851,7 @@ template& m, bufferlist& bl) { - for (typename boost::container::flat_map::const_iterator p - = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl); encode(p->second, bl); } @@ -865,8 +863,7 @@ template& m, bufferlist& bl, uint64_t features) { - for (typename boost::container::flat_map::const_iterator p - = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl, features); encode(p->second, bl, features); } @@ -892,7 +889,7 @@ inline void encode(const std::multimap& m, bufferlist& bl) { __u32 n = (__u32)(m.size()); encode(n, bl); - for (typename std::multimap::const_iterator p = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl); encode(p->second, bl); } @@ -918,7 +915,7 @@ inline void encode(const unordered_map& m, bufferlist& bl, { __u32 n = (__u32)(m.size()); encode(n, bl); - for (typename unordered_map::const_iterator p = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl, features); encode(p->second, bl, features); } @@ -928,7 +925,7 @@ inline void encode(const unordered_map& m, bufferlist& bl) { __u32 n = (__u32)(m.size()); encode(n, bl); - for (typename unordered_map::const_iterator p = m.begin(); p != m.end(); ++p) { + for (auto p = m.begin(); p != m.end(); ++p) { encode(p->first, bl); encode(p->second, bl); } @@ -952,7 +949,7 @@ inline void encode(const ceph::unordered_set& m, bufferlist& { __u32 n = (__u32)(m.size()); encode(n, bl); - for (typename ceph::unordered_set::const_iterator p = m.begin(); p != m.end(); ++p) + for (auto p = m.begin(); p != m.end(); ++p) encode(*p, bl); } template @@ -974,7 +971,7 @@ inline void encode(const std::deque& ls, bufferlist& bl, uint64_t featu { __u32 n = ls.size(); encode(n, bl); - for (typename std::deque::const_iterator p = ls.begin(); p != ls.end(); ++p) + for (auto p = ls.begin(); p != ls.end(); ++p) encode(*p, bl, features); } template @@ -982,7 +979,7 @@ inline void encode(const std::deque& ls, bufferlist& bl) { __u32 n = ls.size(); encode(n, bl); - for (typename std::deque::const_iterator p = ls.begin(); p != ls.end(); ++p) + for (auto p = ls.begin(); p != ls.end(); ++p) encode(*p, bl); } template -- 2.39.5