[PATCH 1/7] libstdc++: Refactor std::uninitialized_{copy, fill, fill_n} algos [PR68350]
Jonathan Wakely
jwakely@redhat.com
Fri Oct 18 15:04:10 GMT 2024
On Fri, 18 Oct 2024 at 15:24, Patrick Palka <ppalka@redhat.com> wrote:
>
> On Fri, 18 Oct 2024, Jonathan Wakely wrote:
>
> > On 16/10/24 21:39 -0400, Patrick Palka wrote:
> > > On Tue, 15 Oct 2024, Jonathan Wakely wrote:
> > > > +#if __cplusplus < 201103L
> > > > +
> > > > + // True if we can unwrap _Iter to get a pointer by using
> > > > std::__niter_base.
> > > > + template<typename _Iter>
> > > > + struct __unwrappable_niter
> > > > + {
> > > > + template<typename> struct __is_ptr { enum { __value = 0 }; };
> > > > + template<typename _Tp> struct __is_ptr<_Tp*> { enum { __value = 1
> > > > }; };
> > > > +
> > > > + typedef __decltype(std::__niter_base(*(_Iter*)0)) _Base;
> > > > +
> > > > + enum { __value = __is_ptr<_Base>::__value };
> > > > + };
> > >
> > > It might be slightly cheaper to define this without the nested class
> > > template as:
> > >
> > > template<typename _Iter, typename _Base =
> > > __decltype(std::__niter_base(*(_Iter*)0))>
> > > struct __unwrappable_niter
> > > { enum { __value = false }; };
> > >
> > > template<typename _Iter, typename _Tp>
> > > struct __unwrappable_niter<_Iter, _Tp*>
> > > { enum { __value = true }; };
>
> One minor nit, we might as well use 'value' since it's a reserved name
> even in C++98?
Huh, I was under the impression it wasn't, but indeed we have
binder1st::value and binder2nd::value!
Why have we been using __value throughout cpp_type_traits.h then!?!
I have indeed pushed it now, but could tweak that, as I'm still
working in that file.
More information about the Libstdc++
mailing list