public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Add gdb::string_view
Date: Sun, 18 Mar 2018 00:11:00 -0000	[thread overview]
Message-ID: <2d68023c-7f24-7eb5-2822-00815b41ba2a@polymtl.ca> (raw)
In-Reply-To: <20180317234902.18278-2-simon.marchi@polymtl.ca>

On 2018-03-17 19:49, Simon Marchi wrote:
> We had a few times the need for a data structure that does essentially
> what C++17's std::string_view does, which is to give an std::string-like
> interface (only the read-only operations) to an arbitrary character
> buffer.
>
> I first copied the string_view file from today's gcc master
> (b427286632d7) and adapted it (I don't think there should be any legal
> issues since the copyright should already belong to the FSF):
>
> - I removed things related to wstring_view, u16string_view and
>   u32string_view (I don't think we need them, but we can always add them
>   later).
> - I removed usages of _GLIBCXX_BEGIN_NAMESPACE_VERSION and
>   _GLIBCXX_END_NAMESPACE_VERSION.
> - I put the code in the gdb namespace.  I had to add a few "std::" in front of
>   std type usages.
> - I added a constructor that builds a string_view from an std::string,
>   so that we can pass strings to string_view parameters seamlessly.
>   Normally, that's handled by "operator __sv_type" in the std::string
>   declaration, but it only exists when building with c++17.
> - When building with >= c++17, gdb::string_view is an alias of
>   std::string_view.
>
> The result is close enough to the original file that if we ever need to
> update it, it should be easy enough to compare it with the new version
> in a diff editor and merge the new changes in.

Hmm, when building with older g++ (such as the aarch64 builders on the buildbot,
which have g++ 4.8), it trips on:

  using __idt = std::common_type_t<_Tp>;

It looks like that release of g++ didn't have std::common_type_t.  I guess it
would be possible to avoid using it, and change these:

    operator==(basic_string_view<_CharT, _Traits> __x,
               __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept

for

    operator==(basic_string_view<_CharT, _Traits> __x,
               basic_string_view<_CharT, _Traits> __y) noexcept

but I am not aware of what consequences it would have.

Simon

  reply	other threads:[~2018-03-18  0:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-17 23:49 [PATCH 1/2] Update ax_cv_cxx_compile_cxx.m4 Simon Marchi
2018-03-17 23:49 ` [PATCH 2/2] Add gdb::string_view Simon Marchi
2018-03-18  0:11   ` Simon Marchi [this message]
2018-03-19 12:21     ` Pedro Alves
2018-03-30 17:43       ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2d68023c-7f24-7eb5-2822-00815b41ba2a@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).