| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3aee762 commit 9075a1a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -598,7 +598,14 @@ constexpr bool FastStringKey::operator==(const FastStringKey& other) const { | |||
| 598 | 598 | return name_ == other.name_; | |
| 599 | 599 | } | |
| 600 | 600 | ||
| 601 | - constexpr FastStringKey::FastStringKey(std::string_view name) | ||
| 601 | + consteval FastStringKey::FastStringKey(std::string_view name) | ||
| 602 | + : FastStringKey(name, 0) {} | ||
| 603 | + | ||
| 604 | + constexpr FastStringKey FastStringKey::AllowDynamic(std::string_view name) { | ||
| 605 | + return FastStringKey(name, 0); | ||
| 606 | + } | ||
| 607 | + | ||
| 608 | + constexpr FastStringKey::FastStringKey(std::string_view name, int dummy) | ||
| 602 | 609 | : name_(name), cached_hash_(HashImpl(name)) {} | |
| 603 | 610 | ||
| 604 | 611 | constexpr std::string_view FastStringKey::as_string_view() const { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -817,7 +817,11 @@ class PersistentToLocal { | |||
| 817 | 817 | // computations. | |
| 818 | 818 | class FastStringKey { | |
| 819 | 819 | public: | |
| 820 | - constexpr explicit FastStringKey(std::string_view name); | ||
| 820 | + // consteval ensures that the argument is a compile-time constant. | ||
| 821 | + consteval explicit FastStringKey(std::string_view name); | ||
| 822 | + // passing something that is not a compile-time constant needs explicit | ||
| 823 | + // opt-in via this helper, as it defeats the purpose of FastStringKey. | ||
| 824 | + static constexpr FastStringKey AllowDynamic(std::string_view name); | ||
| 821 | 825 | ||
| 822 | 826 | struct Hash { | |
| 823 | 827 | constexpr size_t operator()(const FastStringKey& key) const; | |
@@ -827,6 +831,8 @@ class FastStringKey { | |||
| 827 | 831 | constexpr std::string_view as_string_view() const; | |
| 828 | 832 | ||
| 829 | 833 | private: | |
| 834 | + constexpr explicit FastStringKey(std::string_view name, int dummy); | ||
| 835 | + | ||
| 830 | 836 | static constexpr size_t HashImpl(std::string_view str); | |
| 831 | 837 | ||
| 832 | 838 | const std::string_view name_; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments