[libcxx-commits] [PATCH] D129823: [libc++][ranges] Make range algorithms support proxy iterators

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 17 01:59:02 PDT 2022


huixie90 added inline comments.


================
Comment at: libcxx/include/__algorithm/sort.h:34
 
+// Wraps an algorithm policy tag and a comparator in a single struct, used to pass the policy tag around without
+// changing the number of template arguments. This is only used for the "range" policy tag.
----------------
I would also mention the ABI stability in the comments


================
Comment at: libcxx/include/__algorithm/sort.h:71
+template <class _Wrapped>
+struct _UnwrapAlgPolicy<_Wrapped, std::enable_if_t<!std::is_same<typename _Wrapped::_AlgPolicy, int>::value>> {
+  using _AlgPolicy = typename _Wrapped::_AlgPolicy;
----------------
var-const wrote:
> huixie90 wrote:
> > where does the `int` come from? How can a policy be an `int`?
> The expression is meaningless -- I just need to refer to `_Wrapped::_AlgPolicy` in a SFINAE context so that this specialization is preferred when `_Wrapped` is a `_WrapAlgPolicy`.
I was a bit confused and thought you are trying to distinguish between classic policy and range policy. Now I understand that it is for both and distinguish them from the unwrapped ones. Why can't you just do
```
template <class... _Ts>
struct _UnwrapAlgPolicy<_WrapAlgPolicy <Ts...>, void>{
// code
};
```
(we can also remove the second template argument `void` from here and the primary template)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129823/new/

https://reviews.llvm.org/D129823



More information about the libcxx-commits mailing list