[glibmm/wip/dboles/ustring_format_fold_and_test: 1/2] ustring: Use C++17 fold expr. instead of recursion



commit fbe267d6b84ccec41ff3440e9260b471d27af9ad
Author: Daniel Boles <dboles src gnome org>
Date:   Sun Oct 14 13:32:18 2018 +0100

    ustring: Use C++17 fold expr. instead of recursion
    
    Instead of having to manually recurse in order to stream every element
    in the parameter pack, use the new fold expressions, by streaming a
    binary left fold of operator, - to do the same thing in far fewer lines.

 glib/glibmm/ustring.h | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)
---
diff --git a/glib/glibmm/ustring.h b/glib/glibmm/ustring.h
index 739edd93..4135b9a3 100644
--- a/glib/glibmm/ustring.h
+++ b/glib/glibmm/ustring.h
@@ -740,12 +740,6 @@ private:
 
   class FormatStream;
 
-  template<class T>
-  static inline void format_private(FormatStream& buf, const T& arg);
-
-  template<class T1, class... Ts>
-  static inline void format_private(FormatStream& buf, const T1& a1, const Ts&... args);
-
 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
   std::string string_;
@@ -1059,30 +1053,13 @@ ustring::raw() const
   return string_;
 }
 
-template <class T>
-inline // static
-  void
-  ustring::format_private(FormatStream& buf, const T& arg)
-{
-  buf.stream(arg);
-}
-
-template <class T1, class... Ts>
-inline // static
-  void
-  ustring::format_private(FormatStream& buf, const T1& a1, const Ts&... args)
-{
-  buf.stream(a1);
-  return format_private(buf, args...);
-}
-
 template <class... Ts>
 inline // static
   ustring
   ustring::format(const Ts&... args)
 {
   ustring::FormatStream buf;
-  format_private(buf, args...);
+  (buf.stream(args), ...);
   return buf.to_string();
 }
 


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