Removing magic constant from template param check
#3
Merged
SecMeant
merged 3 commits from digits_array
into master
4 years ago
Loading…
Reference in New Issue
There is no content yet.
Delete Branch 'digits_array'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Storing digits in variable, thus removing magic constant from template param check.
This would be a nice improvement; however, it's leaving us with
digits
anddigit_count
in the global scope, which could mess up other code. One solution to that would be to put everything in a namespace, though I haven't done that yet (not sure what to name it). Open to any other solutions if you have them.@tcsullivan
namespace cits // constexpr_integral_to_string
?@ -11,1 +11,4 @@
namespace constexpr_to_string {
constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
inline constexpr
@ -12,0 +12,4 @@
namespace constexpr_to_string {
constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
constexpr auto digit_count = sizeof(digits) / sizeof(digits[0]);
also
inline constexpr
@ -11,1 +11,4 @@
namespace constexpr_to_string {
constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@Neargye why
inline constexpr
whenconstexpr
itself is implicitly inline?@ -11,1 +11,4 @@
namespace constexpr_to_string {
constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
constexpr specifier implies inline for static data members as well as functions, but not for global variable.
https://en.cppreference.com/w/cpp/language/inline
Now, when I think about it, maybe we should use something like
namespace to_string_ { ... }
Since its only purpose is to only hide digits symbols.
@tcsullivan
@SecMeant The
constexpr_to_string
namespace is honestly probably enough. I just realized that the finalto_string
declaration is outside of the namespace, so this isn't actually affecting howto_string
is called (something I was concerned about).I'm good to merge this PR as it is now, if you are.
Sure
Reviewers
6710f1e699
.Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.