Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

涼風青葉提交第1,2,3题 #258

Merged
merged 3 commits into from
Jan 29, 2024
Merged

涼風青葉提交第1,2,3题 #258

merged 3 commits into from
Jan 29, 2024

Conversation

Suzukaze7
Copy link
Collaborator

No description provided.

@Mq-b Mq-b self-assigned this Jan 29, 2024
@Mq-b Mq-b added the category: homework 卢瑟作业 label Jan 29, 2024
#include<functional>

template<typename T, typename Formatter>
T &operator|(T &arr, const Formatter &func) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 这个对齐真抽象。
  2. 既然明确的是返回和接取的是 std::vector,那没必要写 T,写 std::vector<T> 不香吗?
  3. Formatter 模板类型形参的名字与实际作用不符。

};

template<typename T, typename ...U>
void print(T fmt, U ...args) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T fmt, U ...args 极其不规范,应当改为 const T& fmtArgs&&...args


template<typename T, typename ...U>
void print(T fmt, U ...args) {
std::cout << std::vformat(fmt, std::make_format_args(args...));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args... 可以考虑形参包完美转发 std::forward<Args>(args)...

虽然以前实测好像这里改用完美转发并不能提升效率,不过是习惯问题。

Copy link
Owner

@Mq-b Mq-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msvc 的 ci 没有通过,考虑其他问题。

@@ -0,0 +1,16 @@
#include<iostream>
#include<vector>
#include<functional>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缺少头文件 #include <algorithm> 无法在 msvc 通过编译。

@Mq-b Mq-b merged commit 7b87e62 into Mq-b:main Jan 29, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants