-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Use ostream << operator to get to_string #3349
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
Use ostream << operator to get to_string #3349
Conversation
* Make `PADDLE_ENFORCE_EQ` supports custom class, like DDim
paddle/string/to_string_test.cc
Outdated
|
|
||
| // std::to_string might fill zero after float value, like 1.2000 | ||
| for (size_t i = 0; i < my_to_string.size(); ++i) { | ||
| ASSERT_EQ(my_to_string[i], std_to_string[i]); |
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::to_string,直接改成"10", "1.2"来比较吗? 而不是加#if !defined(ANDROID) && !defined(__ANDROID__) 来避免
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.
其实也行。。那我这么干吧。
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.
Done.
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.
LGTM, except the naming for constexpr
paddle/string/to_string_test.cc
Outdated
| #include "paddle/string/to_string.h" | ||
| #include <gtest/gtest.h> | ||
|
|
||
| constexpr char OUT_STR[] = "User Defined Output"; |
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.
https://google.github.io/styleguide/cppguide.html#Constant_Names
Variables declared constexpr or const, and whose value is fixed for the duration of the program, are named with a leading "k" followed by mixed case. For example:
const int kDaysInAWeek = 7;
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.
Done.
PADDLE_ENFORCE_EQsupports custom class, like DDim