Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng
#56 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@reach2sayan đang làm issue này rồi.

Từ ngày 14/10/2026.

  • #57 của @reach2sayan — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
api

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
C++
Star
31
Fork
49
Merge trung bình
1 ngày 13 giờ
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của boostorg/interval

Tất cả issue của boostorg/interval

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.