interval converting constructors and assignment are unconstrained: every type claims to convert
評価
調査の方向性
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
- Overload sets that include an interval become ambiguous.
- Generic libraries that select overloads with
is_convertibleare misled. With Eigen 3.4.0 andEigen::NumTraits<I>specialised,A * Bfor twoEigen::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. - Bad arguments are reported from inside
interval.hppinstead of at the call site.
- 主要言語
- C++
- スター
- 31
- フォーク
- 48
- 平均マージ
- 1日 13時間
- マージ済み PR(30日)
- 6
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
boostorg/interval のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
boostorg/interval の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
content good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
cpinitiative/usaco-guide#6699 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
codepointerapp/codepointer#231 ·
-
enhancement source/qq
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
metasequoiaime/msime-windows#1054 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
amnezia-vpn/amnezia-client#3297 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信