小编Jea*_*Dax的帖子

How to simplify mathematical formulas with rust macros?

I must admit I'm a bit lost with macros. I want to build a macro that does the following task and I'm not sure how to do it. I want to perform a scalar product of two arrays, say x and y, which have the same length N. The result I want to compute is of the form:

z = sum_{i=0}^{N-1} x[i] * y[i].
Run Code Online (Sandbox Code Playgroud)

x is const which elements are 0, 1, or -1 which are known at compile time, …

rust rust-macros

7
推荐指数
1
解决办法
536
查看次数

最佳实践:[[maybe_unused]] 还是匿名参数?

假设我有一个类,其中有一个带有一个参数的虚函数和该虚函数的两个不同实现。第一个实现使用该参数,而第二个实现则不使用该参数。第二种情况会产生编译警告。我可以想到两种方法来抑制警告。

  1. 使用匿名参数。
  2. 使用[[maybe_unused]]注释。

两者之间什么被认为是“最佳实践”?

预先感谢您的回答。

c++ c++14 c++17

2
推荐指数
1
解决办法
574
查看次数

标签 统计

c++ ×1

c++14 ×1

c++17 ×1

rust ×1

rust-macros ×1