为什么 C++23 stacktrace_entry 与 source_location 不同?

Ale*_*iev 8 c++ stack-trace c++23

class stacktrace_entry {
public:
  string description() const;
  string source_file() const;
  uint_least32_t source_line() const;
  /* ... */
};
Run Code Online (Sandbox Code Playgroud)
struct source_location {
  // source location field access
  constexpr uint_least32_t line() const noexcept;
  constexpr uint_least32_t column() const noexcept;
  constexpr const char* file_name() const noexcept;
  constexpr const char* function_name() const noexcept;
  /* ... */
};
Run Code Online (Sandbox Code Playgroud)

它们的目的基本相同,为什么它们有差异,特别是 中没有列stacktrace_entry,或者甚至不共享同一类?

Ale*_*iev 1

提案作者的回答。

关于退货std::string

正如P0881R7中所述:“不幸的是,这在某些平台上是必需的,在这些平台上获取源行需要分配或者源文件名返回到用户提供的存储中。”

关于专栏:

大多数流行的非 Windows 平台解决方案不提供source_column(). 目前std::stacktrace是所有平台能力的最小子集,因此该列缺失。这可以稍后更改,对于 C++ 标准化来说,添加似乎很简单。