Skip to content
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

Apply consteval on appropriate basic_hashed_string related functions #1203

Open
wants to merge 4 commits into
base: wip
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/entt/config/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
#define ENTT_STR(arg) #arg
#define ENTT_XSTR(arg) ENTT_STR(arg)

#define ENTT_CONSTEVAL constexpr

#if __has_include(<version>)
# include <version>
#
# if defined(__cpp_consteval)
# undef ENTT_CONSTEVAL
# define ENTT_CONSTEVAL consteval
# endif
#endif

// NOLINTEND(cppcoreguidelines-macro-usage)

#endif
8 changes: 4 additions & 4 deletions src/entt/core/hashed_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class basic_hashed_string: internal::basic_hashed_string<Char> {
*/
template<std::size_t N>
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
[[nodiscard]] static constexpr hash_type value(const value_type (&str)[N]) noexcept {
[[nodiscard]] static ENTT_CONSTEVAL hash_type value(const value_type (&str)[N]) noexcept {
return basic_hashed_string{str};
}

Expand Down Expand Up @@ -137,7 +137,7 @@ class basic_hashed_string: internal::basic_hashed_string<Char> {
*/
template<std::size_t N>
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
constexpr basic_hashed_string(const value_type (&str)[N]) noexcept
ENTT_CONSTEVAL basic_hashed_string(const value_type (&str)[N]) noexcept
: base_type{helper({static_cast<const value_type *>(str)})} {}

/**
Expand Down Expand Up @@ -291,7 +291,7 @@ inline namespace literals {
* @param str The literal without its suffix.
* @return A properly initialized hashed string.
*/
[[nodiscard]] constexpr hashed_string operator""_hs(const char *str, std::size_t) noexcept {
[[nodiscard]] ENTT_CONSTEVAL hashed_string operator""_hs(const char *str, std::size_t) noexcept {
return hashed_string{str};
}

Expand All @@ -300,7 +300,7 @@ inline namespace literals {
* @param str The literal without its suffix.
* @return A properly initialized hashed wstring.
*/
[[nodiscard]] constexpr hashed_wstring operator""_hws(const wchar_t *str, std::size_t) noexcept {
[[nodiscard]] ENTT_CONSTEVAL hashed_wstring operator""_hws(const wchar_t *str, std::size_t) noexcept {
return hashed_wstring{str};
}

Expand Down
Loading