[libcxx-commits] [PATCH] D115315: [libc++][ranges] Implement ranges::uninitialized_default_construct{, _n}.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 13 13:10:41 PST 2021


ldionne added inline comments.


================
Comment at: libcxx/include/__memory/ranges_uninitialized_algorithms.h:39
+
+struct __uninitialized_default_construct_fn final : private __function_like {
+
----------------
This should be called `__fn` so that it shows up consistently to other CPOs in compiler diagnostics.


================
Comment at: libcxx/include/__memory/ranges_uninitialized_algorithms.h:37
+
+struct __uninitialized_default_construct_fn final : private __function_like {
+
----------------
var-const wrote:
> Quuxplusone wrote:
> > This should be as in the blog post too:
> > ```
> > namespace __uninitialized_default_construct {
> > struct __fn {
> > };
> > } // namespace __uninitialized_default_construct
> > ```
> > AIUI, this keeps the CPO's own type from ADL'ing into the `std::ranges` namespace; e.g. `foobar(std::ranges::uninitialized_default_construct)` should not consider `std::ranges::foobar` a candidate //even if std::ranges::foobar is not a CPO itself.//
> > Also, of course, consistency (Chesterton's Fence, the economist's hundred-dollar bill): if it were safe to omit the namespace, we'd certainly want to do it everywhere, not just here.
> Done (I added an `_ns` suffix to the namespace name to make sure it's different from the name of the helper functions). Do we actually need a separate namespace for each CPO, though?
> 
> By the way, can you please elaborate on how this could be a problem, given that the type of the CPO is an underscore-prefixed internal type?
I *think* we could instead have a single namespace named something like `__cpo_detail` and then instead name our helpers `__uninitialized_default_construct_fn`. We could explore that in a separate PR, but for the time being let's be consistent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115315



More information about the libcxx-commits mailing list