Idiomatic way to cast or convert between different r_vector types

オープン
#264 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp, r
領域
documentation

調査の方向性

Start with the conversion section of the vignette at the linked “fewer implicit conversions” heading, then inspect the cpp11::as_cpp examples and the Rf_coerceVector usage described in the issue. Document the idiomatic conversion between r_vector types and clarify whether the converted vector needs protection; done means the vignette answers both questions with a supported example.

索引モデルが issue の本文から書いたものです。

説明

The following conversions results in a run time error Invalid input type, expected 'integer' actual 'logical'

// cpp11::logicals val
cpp11::integers ints(val);
cpp11::integers ints = cpp11::as_cpp<cpp11::integers>(val);

It's not clear to me why logicals cannot be re-interpreted as integers. After all it's the same internal representation.

What is an idiomatic way to convert within cpp11 when converting at R level is not an option? Is it enough to cpp11::integers X2(Rf_coerceVector(X, INTSXP));, or do I still need to protect the converted vector?

It would be great if this information could be added to the conversion section of the vignette.

Thanks!
`

主要言語
C++
スター
224
フォーク
52
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

r-lib/cpp11 のほかの issue

r-lib/cpp11 の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。