[libcxx-commits] [PATCH] D137476: [libc++] Add utilites for instantiating functions with multiple types
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 21 08:13:25 PST 2022
ldionne accepted this revision.
ldionne added inline comments.
================
Comment at: libcxx/test/support/test_iterators.h:1302-1314
+template <class T>
+using random_access_iterator_list = type_list<T, contiguous_iterator<T>, random_access_iterator<T>>;
+
+template <class T>
+using bidirectional_iterator_list = concatenate_t<random_access_iterator_list<T>, type_list<bidirectional_iterator<T>>>;
+
+template <class T>
----------------
For a second I thought `T` was the `value_type`.
================
Comment at: libcxx/test/support/type_algorithms.h:21-25
+// - T -> type_list<T>
+// - T, U -> type_list<T, U>
+// - type_list<Ts...> -> type_list<Ts...>
+// - type_list<Ts...>, T -> type_list<Ts..., T>
+// - N type_lists to one
----------------
philnik wrote:
> ldionne wrote:
> > ~~This feels a bit loose to me. I would only concatenate type lists together, not arbitrary types.~~
> >
> > ~~Otherwise, this breaks "generic programming" (not that we would want to do that in the test suite, but I still think it illustrates why this is surprising). Instead, if we need that functionality, I would call it something like `append<list, type>`, but I'm not sure we actually need that.~~
> >
> > After our experiment, I think we agreed that `concatenate` and even `cartesian_product` can go away, at least for now.
> I agreed, but after looking again at the standard I think it makes sense to keep the `type_list`-concatenating parts. Specifically, `intergal types`, `floating-point types` and `arithmetic types` are specified in terms of other groups of types. I think it makes sense to follow the wording of the standard in code to make it trivial to verify. For example, `arithmetic types` is specified like this: `Integral and floating-point types are collectively termed arithmetic types.`. Written in code it's `using arithmetic_types = concatenate_t<integral_types, floating_point_types>;`.
Ok, agreed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137476/new/
https://reviews.llvm.org/D137476
More information about the libcxx-commits
mailing list