-
Notifications
You must be signed in to change notification settings - Fork 137
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
涼風青葉提交第1,2,3题 #258
Conversation
src/群友提交/第01题/涼風青葉.cpp
Outdated
#include<functional> | ||
|
||
template<typename T, typename Formatter> | ||
T &operator|(T &arr, const Formatter &func) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 这个对齐真抽象。
- 既然明确的是返回和接取的是
std::vector
,那没必要写T
,写std::vector<T>
不香吗? Formatter
模板类型形参的名字与实际作用不符。
src/群友提交/第03题/涼風青葉.cpp
Outdated
}; | ||
|
||
template<typename T, typename ...U> | ||
void print(T fmt, U ...args) { |
There was a problem hiding this comment.
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& fmt
、Args&&...args
。
src/群友提交/第03题/涼風青葉.cpp
Outdated
|
||
template<typename T, typename ...U> | ||
void print(T fmt, U ...args) { | ||
std::cout << std::vformat(fmt, std::make_format_args(args...)); |
There was a problem hiding this comment.
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)...
。
虽然以前实测好像这里改用完美转发并不能提升效率,不过是习惯问题。
There was a problem hiding this 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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺少头文件 #include <algorithm>
无法在 msvc
通过编译。
No description provided.