[PATCH] D27679: WIP: simplify format member detection in FormatVariadic

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 09:41:56 PST 2016

zturner added inline comments.

Comment at: include/llvm/Support/FormatVariadicDetails.h:22-23
 namespace detail {
+class format_adapter {};
What if we added `virtual void format(llvm::raw_ostream &Stream, StringRef Style) const = 0;` to this class?

This would guaranteed that if the `is_base_of` check ever succeeded, it would never fail to compile because of a missing format member.

Comment at: include/llvm/Support/FormatVariadicDetails.h:25-32
+template<typename T>
+class format_adapter: public detail::format_adapter {
+  typedef T type;
+  explicit format_adapter(T Item) : Item(Item) {}
+  T Item;
Do we actually need the templated version of this class?  Why not just have `AdapterBase` inherit directly from `format_adapter`?  It seems like `AdapterBase<T>` and `format_adapter<T>` could be merged into 1 class.


More information about the llvm-commits mailing list