Title
Is std::basic_stacktrace required to use contiguous storage?
Status
new
Section
[stacktrace.basic.overview]
Submitter
Jiang An

Created on 2021-10-23.00:00:00 last changed 1 month ago

Messages

Date: 2021-10-27.18:23:02

Proposed resolution:

This wording is relative to N4901.

[Drafting note: The proposed wording below contains also conditional changes, it is therefore depending upon a decision]

  1. Modify [stacktrace.basic.overview] as indicated:

    -1- The class template basic_stacktrace satisfies the requirements of an allocator-aware container (Table 80 [tab:container.alloc.req]), a sequence container ([sequence.reqmts]), a contiguous container, and a reversible container ([container.requirements.general]) except that […]

  2. Modify [stacktrace.basic.obs] as indicated:

    using const_iterator = implementation-defined;
    

    -1- The type models random_access_iteratorcontiguous_iterator ([iterator.concept.random.access][iterator.concept.contiguous]) and meets the Cpp17RandomAccessIterator requirements ([random.access.iterators]).

Optional additional changes (the following parts are proposed only if data() is wanted)

  1. Modify [stacktrace.basic.overview], class template basic_stacktrace synopsis, as indicated:

    […]
    const_reference operator[](size_type) const;
    const_reference at(size_type) const;
    
    const stacktrace_entry* data() const noexcept;
    
    // [stacktrace.basic.cmp], comparisons
    […]
    
  2. Modify [stacktrace.basic.obs] as indicated:

    const_reference at(size_type frame_no) const;
    

    -13- […]

    -14- […]

    const stacktrace_entry* data() const noexcept;
    

    -?- Returns: frames_.data().

Date: 2021-10-23.00:00:00

Currently std::basic_stacktrace has an exposition-only std::vector member for storing its elements. According to [objects.within.classes]/3, it seems that it is effectively required that elements of a std::basic_stacktrace are contiguously stored. However, the implication seems not used otherwhere. The iterator type of a std::basic_stacktrace is only required to be random access iterator.

IMO if it is required that std::basic_stacktrace uses contiguous storage, we should explicitly strengthen some requirements, perhaps a the member function data should be added.

History
Date User Action Args
2021-10-24 12:00:40adminsetmessages: + msg12197
2021-10-23 00:00:00admincreate