Compilation issue with custom state type with clang only
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với reproducer Godbolt được liên kết và so sánh clang++ với các trình biên dịch chấp nhận nó. Kiểm tra đường dẫn include của boost/numeric/odeint.hpp và việc sử dụng vector_space_algebra với std::pair; hoàn tất nghĩa là chương trình được hiển thị biên dịch được bằng clang++ mà không di chuyển các định nghĩa toán tử lên trước include odeint.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In the code below, I am working with a custom state-type (a std::pair in this case). The code compiles with g++, icc, msvc. With clang however, compilation fails. In order to get it to build successfully, I apparently need to define operator+() and operator*() for the state type before including the odeint header. Link to godbolt: https://godbolt.org/z/6eavzdxbf
#include <cstdlib>
#include <utility>
#include <boost/numeric/odeint.hpp> // if included here, compilations fails with clang++
using state_type = std::pair<double, double>;
using deriv_type = state_type;
using time_type = double;
state_type operator+(state_type a, state_type const& b);
state_type operator*(state_type a, time_type b);
state_type operator*(time_type b, state_type a);
//~ #include <boost/numeric/odeint.hpp> // if included here, no error!
state_type operator+(state_type a, state_type const& b) {
a.first += b.first;
a.second += b.second;
return a;
}
state_type operator*(state_type a, time_type b) {
a.first *= b;
a.second *= b;
return a;
}
state_type operator*(time_type b, state_type a) {
return a * b;
}
void harmonic_oscillator(const state_type& x, deriv_type& dxdt, time_type) {
static auto constexpr gam = 0.1;
dxdt.first = x.second;
dxdt.second = -x.first - gam*x.second;
}
namespace bno = boost::numeric::odeint;
using stepper_type = bno::runge_kutta_dopri5<state_type, double, deriv_type, time_type, bno::vector_space_algebra>;
int main() {
state_type x0{1.0, 0.0};
// just to see if the operators work...
x0 * 1.;
2. * x0;
x0 + x0;
stepper_type stepper;
time_type const dt = 0.005;
for (time_type t = 0; t < 10; t += dt) {
stepper.do_step(harmonic_oscillator, x0, t, dt);
std::cout << t << '\t' << x0.first << '\t' << x0.second << '\n';
}
return EXIT_SUCCESS;
}
- Ngôn ngữ chính
- C++
- Star
- 55
- Fork
- 59
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của boostorg/odeint
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 43/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Tất cả issue của boostorg/odeint
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
sandialabs/seacas#945 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ROCm/FastFlowLM#757 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
WaterHeaterManagement: tank_percent feature reports wrong feature id (FeatureMap corruption)Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
espressif/esp-matter#1867 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mltframework/shotcut#1920 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày