On 26/03/2023 04:01, Ken Matsui via Libstdc++ wrote:
On Sat, Mar 25, 2023 at 5:38 AM Marc Glisse <marc.gli...@inria.fr> wrote:
On Sat, 25 Mar 2023, Ken Matsui via Gcc wrote:

Built-in trait naming simply adds two underscores (__) to the original
trait name. However, the same names are already in use for some
built-in traits, such as is_void, is_pointer, and is_signed.

For example, __is_void is used in the following files:

* gcc/testsuite/g++.dg/tm/pr46567.C
This is a testcase, you can rename __is_void to whatever in there, it
doesn't matter.

* libstdc++-v3/include/bits/cpp_type_traits.h
This __is_void seems to be used in a single place in
include/debug/helper_functions.h, couldn't we tweak that code so __is_void
becomes unused and can be removed?
That worked. Thank you!
What worked ?

So, we can remove a code in a header as long as it is not standard and
is not used elsewhere, can't we?

You can do anything you like as long as you run the testsuite before presenting your patch. Here note that you'll need to run:

make check-debug

to run tests in _GLIBCXX_DEBUG mode which is making use of the code in helper_functions.h.

Clearly this usage of std::__is_void could be replaced with your builtin by reimplementing _Distance_traits like this:

  template<typename _Iterator,
       typename = typename std::__is_integer<_Iterator>::__type>
    struct _Distance_traits
    {
    private:
      typedef
    typename std::iterator_traits<_Iterator>::difference_type _ItDiffType;

      typedef
    typename std::conditional<__is_void<_ItDiffType>,
                  std::ptrdiff_t, _ItDiffType>::type _DiffType;

    public:
      typedef std::pair<_DiffType, _Distance_precision> __type;
    };

this is untested, just to give you an idea of what your patch could be.

François


Reply via email to