cpprefjp / site

cpprefjpサイトのMarkdownソース
https://cpprefjp.github.io/
368 stars 153 forks source link

Fix range_formatter and formattable #1155

Closed acd1034 closed 1 year ago

acd1034 commented 1 year ago

<format>のリファレンスについて、些細ですが気になる点がありましたので、PRを作成しました。

range_formatterのオリジナル書式を定義する例について

// 修正前
auto format(MyVector<T>&& v, std::format_context& fctx) const {

// 修正後
auto format(const MyVector<T>& v, std::format_context& fctx) const {

formatMyVectorを受け取る引数が右辺値参照になっているため、左辺値を受け取るサンプルコードは動作しないのではないかと思います。MyVectorは、const-formattable-rangeにできない理由もないため、const左辺値参照にするのが適切ではないかと思い、修正しました。

formattableコンセプトのfmt-iter-forについて

// 修正前
template <class charT>
concept fmt-iter-for = output_iterator<const charT&>;

// 修正後
template <class charT>
using fmt-iter-for = /* unspecified */;

fmt-iter-forについて、P2286R8(該当箇所へのリンク)には、

Let fmt-iter-for<charT> be an unspecified type that models output_iterator<const charT&> (fmt-iter-for<charT>output_iterator<const charT&>コンセプトのモデルとなる未規定の型とする)

とありますので、fmt-iter-forはコンセプトではなく、未規定の型であるとの表現が適切ではないかと思い、修正しました。

faithandbrave commented 1 year ago

ありがとうございます。マージしました。