Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Introducing `variable_t` and similar types for convenience

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
api

調査の方向性

まず、既存の boost::histogram::axis::variable の定義と関連するテストを見つけます。この issue ではソースファイルやテストのエントリーポイントは指定されていません。提示された C++ の例で要求されている variable_t の動作を比較し、説明どおりに同等のオプション型を代入して検査できれば、作業完了とみなします。

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

説明

    @HDembinski Here are some examples why using `variable_t` can bring convenience.
std::is_same_v<
    boost::histogram::axis::variable<double, std::string, boost::use_default>,
    boost::histogram::axis::variable<double, std::string, decltype(boost::histogram::axis::option::underflow | boost::histogram::axis::option::overflow)>
>

is false,

std::is_same_v<
    boost::histogram::axis::variable_t<double, std::string, boost::use_default>,
    boost::histogram::axis::variable_t<double, std::string, decltype(boost::histogram::axis::option::underflow | boost::histogram::axis::option::overflow)>
>

is true;


This causes a compile error:

boost::histogram::axis::variable<double, std::string, boost::use_default> a;
boost::histogram::axis::variable<double, std::string, decltype(boost::histogram::axis::option::underflow | boost::histogram::axis::option::overflow)> b;
a = b;

This does not cause a compile error:

boost::histogram::axis::variable_t<double, std::string, boost::use_default> a;
boost::histogram::axis::variable_t<double, std::string, decltype(boost::histogram::axis::option::underflow | boost::histogram::axis::option::overflow)> b;
a = b;

In templates, you can get the meta type, options type, allocator type conveniently if template users write variable_t, not if template users write variable:

template<typename V, typename M, typename O, typename A>
void f(boost::histogram::axis::variable<V, M, O, A>)
{
    std::cout << typeid(V).name() << '\n';
    std::cout << typeid(M).name() << '\n';
    std::cout << typeid(O).name() << '\n';
    std::cout << typeid(A).name() << '\n';
}

int main(int argc, char *argv[])
{
    f(boost::histogram::axis::variable<>());
    //double
    //struct boost::use_default
    //struct boost::use_default
    //class std::allocator<double>

    f(boost::histogram::axis::variable_t<>());
    //double
    //class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
    //struct boost::histogram::axis::option::bitset<3>
    //class std::allocator<double>
}

In debugger, you can not see what options a has but can see what options b has:
image

boost::histogram::axis::variable<> a;
boost::histogram::axis::variable_t<> b;

Originally posted by @jhcarl0814 in https://github.com/boostorg/histogram/issues/372#issuecomment-1364494250

主要言語
C++
スター
334
フォーク
75
平均マージ
18時間 2分
マージ済み PR(30日)
2

環境構築

はじめの一歩

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

boostorg/histogram のほかの issue

boostorg/histogram の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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