On Wed, 12 Jul 2023 at 21:42, Ken Matsui <kmat...@cs.washington.edu> wrote:
>
> On Wed, Jul 12, 2023 at 3:01 AM Jonathan Wakely <jwak...@redhat.com> wrote:
> >
> > On Mon, 10 Jul 2023 at 06:51, Ken Matsui via Libstdc++
> > <libstd...@gcc.gnu.org> wrote:
> > >
> > > Hi,
> > >
> > > Here is the benchmark result for is_pointer:
> > >
> > > https://github.com/ken-matsui/gcc-benches/blob/main/is_pointer.md#sun-jul--9-103948-pm-pdt-2023
> > >
> > > Time: -62.1344%
> > > Peak Memory Usage: -52.4281%
> > > Total Memory Usage: -53.5889%
> >
> > Wow!
> >
> > Although maybe we could have improved our std::is_pointer_v anyway, like so:
> >
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v = false;
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v<_Tp*> = true;
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v<_Tp* const> = true;
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v<_Tp* volatile> = true;
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v<_Tp* const volatile> = true;
> >
> > I'm not sure why I didn't already do that.
> >
> > Could you please benchmark that? And if it is better than the current
> > impl using is_pointer<_Tp>::value then we should do this in the
> > library:
> >
> > #if __has_builtin(__is_pointer)
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v = __is_pointer(_Tp);
> > #else
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v = false;
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v<_Tp*> = true;
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v<_Tp* const> = true;
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v<_Tp* volatile> = true;
> > template <typename _Tp>
> >   inline constexpr bool is_pointer_v<_Tp* const volatile> = true;
> > #endif
>
> Hi François and Jonathan,
>
> Thank you for your reviews! I will rename the four underscores to the
> appropriate name and take a benchmark once I get home.
>
> If I apply your change on is_pointer_v, is it better to add the
> `Co-authored-by:` line in the commit?

Yes, that would be the correct thing to do (although in this case the
change is small enough that I don't really care about getting credit
for it :-)

Reply via email to