This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA v2 1/7] Remove some ui_out-related cleanups from Python


On 2017-02-09 16:24, Tom Tromey wrote:
This patch introduces a bit of infrastructure -- namely, a minimal
std::optional analogue called gdb::optional, and an RAII template
class that works like make_cleanup_ui_out_tuple_begin_end or
make_cleanup_ui_out_list_begin_end -- and then uses these in the
Python code.  This removes a number of cleanups and generally
simplifies this code.

std::optional is only available in C++17.  Normally I would have had
this code check __cplusplus, but my gcc apparently isn't new enough to
find <optional>, even with -std=c++1z; so, because I could not test
it, the patch does not do this.

I am curious what are the differences between using an std::optional and a std::unique_ptr. Obviously

  std::optional<Foo> opt;
  std::unique_ptr<Foo> ptr;

  opt.emplace (arg);
  ptr.reset (new Foo (arg));

The obvious one is stack memory allocation for optional and heap for unique_ptr, but apart from that, any difference in the functionality?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]