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

interval converting constructors and assignment are unconstrained: every type claims to convert

クローズ
#56 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@reach2sayan がすでに取り組んでいます。

2026年10月14日 から。

  • #57 @reach2sayan による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp
領域
api

調査の方向性

The unconstrained converting constructors and operator= are declared in interval.hpp, so start there and check which overloads accept any T1. Constrain them so only intended arithmetic types convert, then compile the static_asserts from the issue to confirm std::is_convertible is false for std::string, unrelated and void*. Pull request #57 already targets this, so read it and coordinate with its author before starting.

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

説明

Follow-up to #47, as requested there.

interval<T, Policies> declares (interval.hpp, develop at 3957843):

  template<class T1> interval(T1 const &v);
  template<class T1, class T2> interval(T1 const &l, T2 const &u);
  template<class T1> interval &operator=(T1 const &v);

None of them is constrained, and the constructors are not explicit. So an interval claims to be implicitly convertible from any type. This compiles:

  #include <boost/numeric/interval.hpp>
  #include <string>
  #include <type_traits>

  typedef boost::numeric::interval<double> I;
  struct unrelated {};

  static_assert(std::is_convertible<std::string, I>::value, "");
  static_assert(std::is_convertible<unrelated, I>::value, "");
  static_assert(std::is_convertible<void*, I>::value, "");
  static_assert(std::is_constructible<I, std::string, unrelated>::value, "");
  static_assert(std::is_assignable<I&, std::string>::value, "");

  int main() {}

Effects

  1. Overload sets that include an interval become ambiguous.
  2. Generic libraries that select overloads with is_convertible are misled. With Eigen 3.4.0 and Eigen::NumTraits<I> specialised, A * B for two Eigen::Matrix<I, 2, 2> is ambiguous, because the scalar-times-matrix overloads see the matrix as convertible to the scalar type. A.lazyProduct(B) works. This is the case from #47.
  3. Bad arguments are reported from inside interval.hpp instead of at the call site.

godbolt

主要言語
C++
スター
31
フォーク
48
平均マージ
1日 13時間
マージ済み PR(30日)
6

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

boostorg/interval のほかの issue

boostorg/interval の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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