Removing magic constant from template param check #3

Merged
SecMeant merged 3 commits from digits_array into master 2020-06-29 15:17:39 -04:00
SecMeant commented 2020-06-26 19:23:48 -04:00 (Migrated from github.com)

Storing digits in variable, thus removing magic constant from template param check.

Storing digits in variable, thus removing magic constant from template param check.
tcsullivan commented 2020-06-26 20:50:37 -04:00 (Migrated from github.com)

This would be a nice improvement; however, it's leaving us with digits and digit_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.

This would be a nice improvement; however, it's leaving us with `digits` and `digit_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.
Neargye commented 2020-06-27 12:20:27 -04:00 (Migrated from github.com)

@tcsullivan namespace cits // constexpr_integral_to_string ?

@tcsullivan `namespace cits // constexpr_integral_to_string` ?
Neargye (Migrated from github.com) requested changes 2020-06-27 12:45:33 -04:00
@ -11,1 +11,4 @@
namespace constexpr_to_string {
constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Neargye (Migrated from github.com) commented 2020-06-27 12:20:45 -04:00

inline constexpr

`inline constexpr `
@ -12,0 +12,4 @@
namespace constexpr_to_string {
constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
constexpr auto digit_count = sizeof(digits) / sizeof(digits[0]);
Neargye (Migrated from github.com) commented 2020-06-27 12:20:55 -04:00

also inline constexpr

also `inline constexpr`
m-peko (Migrated from github.com) reviewed 2020-06-29 08:43:29 -04:00
@ -11,1 +11,4 @@
namespace constexpr_to_string {
constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
m-peko (Migrated from github.com) commented 2020-06-29 08:43:29 -04:00

@Neargye why inline constexpr when constexpr itself is implicitly inline?

@Neargye why `inline constexpr` when `constexpr` itself is implicitly inline?
Neargye (Migrated from github.com) reviewed 2020-06-29 08:47:46 -04:00
@ -11,1 +11,4 @@
namespace constexpr_to_string {
constexpr char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Neargye (Migrated from github.com) commented 2020-06-29 08:47:46 -04:00

​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

​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
SecMeant commented 2020-06-29 13:35:54 -04:00 (Migrated from github.com)

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

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
tcsullivan commented 2020-06-29 13:51:21 -04:00 (Migrated from github.com)

@SecMeant The constexpr_to_string namespace is honestly probably enough. I just realized that the final to_string declaration is outside of the namespace, so this isn't actually affecting how to_string is called (something I was concerned about).

I'm good to merge this PR as it is now, if you are.

@SecMeant The `constexpr_to_string` namespace is honestly probably enough. I just realized that the final `to_string` declaration is outside of the namespace, so this isn't actually affecting how `to_string` is called (something I was concerned about). I'm good to merge this PR as it is now, if you are.
SecMeant commented 2020-06-29 15:06:29 -04:00 (Migrated from github.com)

Sure

Sure
Sign in to join this conversation.
No description provided.