diff --git a/flake.nix b/flake.nix index 29aa810..fc72d71 100644 --- a/flake.nix +++ b/flake.nix @@ -41,7 +41,6 @@ vulkan-extension-layer vulkan-memory-allocator vulkan-utility-libraries - vulkan-headers vulkan-loader vulkan-tools ]; diff --git a/src/main.cpp b/src/main.cpp index 7085320..a808475 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,6 @@ +#define VULKAN_HPP_NO_CONSTRUCTORS +#include + #define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_VULKAN #include @@ -11,7 +14,6 @@ #include #include #include -#include #include "util/magic_enum.hpp" #include "util/types.h" @@ -144,44 +146,41 @@ class Application { if (enableValidationLayers && !checkValidationLayerSupport()) throw std::runtime_error("validation layers requested, but not available!"); - VkApplicationInfo appInfo {}; - appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; - appInfo.pApplicationName = "Hello Triangle"; - appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); - appInfo.pEngineName = "No Engine"; - appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0); - appInfo.apiVersion = VK_API_VERSION_1_0; + vk::ApplicationInfo appInfo { .pApplicationName = "Hello Triangle", + .applicationVersion = 1, + .pEngineName = "No Engine", + .engineVersion = 1, + .apiVersion = VK_API_VERSION_1_1 }; - VkInstanceCreateInfo createInfo {}; - createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - createInfo.pApplicationInfo = &appInfo; + vk::InstanceCreateInfo createInfo { .pApplicationInfo = &appInfo }; + // Retrieve extensions using custom function std::vector extensions = getRequiredExtensions(); - VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo {}; + vk::DebugUtilsMessengerCreateInfoEXT debugCreateInfo {}; if (enableValidationLayers) { - createInfo.enabledLayerCount = static_cast(validationLayers.size()); - createInfo.ppEnabledLayerNames = validationLayers.data(); + createInfo.setEnabledLayerCount(static_cast(validationLayers.size())) + .setPpEnabledLayerNames(validationLayers.data()); populateDebugMessengerCreateInfo(debugCreateInfo); - createInfo.pNext = static_cast(&debugCreateInfo); + createInfo.setPNext(&debugCreateInfo); } else { - createInfo.enabledLayerCount = 0; - - createInfo.pNext = nullptr; + createInfo.setEnabledLayerCount(0).setPNext(nullptr); } - extensions.emplace_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME); - - createInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR; - - createInfo.enabledExtensionCount = static_cast(extensions.size()); - createInfo.ppEnabledExtensionNames = extensions.data(); + // Enable the portability extension and set flags + extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME); + createInfo.setEnabledExtensionCount(static_cast(extensions.size())) + .setPpEnabledExtensionNames(extensions.data()) + .setFlags(vk::InstanceCreateFlagBits::eEnumeratePortabilityKHR); for (const char* extension : extensions) std::cout << extension << std::endl; - if (vkCreateInstance(&createInfo, nullptr, &mInstance) != VK_SUCCESS) - throw std::runtime_error("failed to create instance!"); + try { + mInstance = vk::createInstance(createInfo); + } catch (const vk::SystemError& err) { + throw std::runtime_error("Failed to create instance: " + std::string(err.what())); + } } static fn populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo) -> void { diff --git a/src/util/magic_enum.hpp b/src/util/magic_enum.hpp index 20ca352..c728df6 100644 --- a/src/util/magic_enum.hpp +++ b/src/util/magic_enum.hpp @@ -78,16 +78,15 @@ #elif defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // May be used uninitialized 'return {};'. -#pragma GCC diagnostic ignored "-Wuseless-cast" // suppresses 'static_cast('\0')' for - // char_type = char (common on Linux). +#pragma GCC diagnostic ignored "-Wuseless-cast" // suppresses 'static_cast('\0')' for + // char_type = char (common on Linux). #elif defined(_MSC_VER) #pragma warning(push) #pragma warning(disable : 26495) // Variable 'static_str::chars_' is uninitialized. #pragma warning(disable : 28020) // Arithmetic overflow: Using operator '-' on a 4 byte value and // then casting the result to a 8 byte value. -#pragma warning(disable : 26451 \ -) // The expression '0<=_Param_(1)&&_Param_(1)<=1-1' is not true at this call. -#pragma warning(disable : 4514) // Unreferenced inline function has been removed. +#pragma warning(disable : 26451) // The expression '0<=_Param_(1)&&_Param_(1)<=1-1' is not true at this call. +#pragma warning(disable : 4514) // Unreferenced inline function has been removed. #endif // Checks magic_enum compiler compatibility. @@ -163,10 +162,8 @@ namespace magic_enum { static_assert( [] { if constexpr (std::is_same_v) { - constexpr const char c[] = - "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|"; - constexpr const wchar_t wc[] = - L"abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|"; + constexpr const char c[] = "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|"; + constexpr const wchar_t wc[] = L"abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|"; static_assert( std::size(c) == std::size(wc), "magic_enum::customize identifier characters are multichars in wchar_t." @@ -209,8 +206,7 @@ namespace magic_enum { class customize_t : public std::pair { public: constexpr customize_t(string_view srt) - : std::pair { detail::customize_tag::custom_tag, srt } { - } + : std::pair { detail::customize_tag::custom_tag, srt } {} constexpr customize_t(const char_type* srt) : customize_t { string_view { srt } } {} constexpr customize_t(detail::customize_tag tag) : std::pair { tag, string_view {} } { @@ -249,10 +245,7 @@ namespace magic_enum { }; #endif - template < - auto V, - typename E = std::decay_t, - std::enable_if_t, int> = 0> + template , std::enable_if_t, int> = 0> using enum_constant = std::integral_constant; template @@ -263,26 +256,22 @@ namespace magic_enum { template struct has_is_flags::is_flags)>> - : std::bool_constant< - std::is_same_v::is_flags)>>> {}; + : std::bool_constant::is_flags)>>> { + }; template struct range_min : std::integral_constant {}; template struct range_min::min)>> - : std::integral_constant< - decltype(customize::enum_range::min), - customize::enum_range::min> {}; + : std::integral_constant::min), customize::enum_range::min> {}; template struct range_max : std::integral_constant {}; template struct range_max::max)>> - : std::integral_constant< - decltype(customize::enum_range::max), - customize::enum_range::max> {}; + : std::integral_constant::max), customize::enum_range::max> {}; struct str_view { const char* str_ = nullptr; @@ -340,9 +329,7 @@ namespace magic_enum { class case_insensitive { static constexpr char_type to_lower(char_type c) noexcept { return (c >= static_cast('A') && c <= static_cast('Z')) - ? static_cast( - c + (static_cast('a') - static_cast('A')) - ) + ? static_cast(c + (static_cast('a') - static_cast('A'))) : c; } @@ -381,8 +368,7 @@ namespace magic_enum { template constexpr bool is_default_predicate() noexcept { - return std:: - is_same_v, std::equal_to> || + return std::is_same_v, std::equal_to> || std::is_same_v, std::equal_to<>>; } @@ -393,11 +379,9 @@ namespace magic_enum { } template - constexpr bool cmp_equal( - string_view lhs, - string_view rhs, - [[maybe_unused]] BinaryPredicate&& p - ) noexcept(is_nothrow_invocable()) { + constexpr bool cmp_equal(string_view lhs, string_view rhs, [[maybe_unused]] BinaryPredicate&& p) noexcept( + is_nothrow_invocable() + ) { #if defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__) // https://developercommunity.visualstudio.com/content/problem/360432/vs20178-regression-c-failed-in-test.html // https://developercommunity.visualstudio.com/content/problem/232218/c-constexpr-string-view.html @@ -427,8 +411,7 @@ namespace magic_enum { template constexpr bool cmp_less(L lhs, R rhs) noexcept { static_assert( - std::is_integral_v && std::is_integral_v, - "magic_enum::detail::cmp_less requires integral type." + std::is_integral_v && std::is_integral_v, "magic_enum::detail::cmp_less requires integral type." ); if constexpr (std::is_signed_v == std::is_signed_v) { @@ -465,8 +448,7 @@ namespace magic_enum { #define MAGIC_ENUM_ARRAY_CONSTEXPR 1 #else template - constexpr std::array, N> - to_array(T (&a)[N], std::index_sequence) noexcept { + constexpr std::array, N> to_array(T (&a)[N], std::index_sequence) noexcept { return { { a[I]... } }; } #endif @@ -561,14 +543,11 @@ namespace magic_enum { if constexpr (supported::value) { #if defined(MAGIC_ENUM_GET_ENUM_NAME_BUILTIN) constexpr auto name_ptr = MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V); - auto name = - name_ptr ? str_view { name_ptr, std::char_traits::length(name_ptr) } : str_view {}; + auto name = name_ptr ? str_view { name_ptr, std::char_traits::length(name_ptr) } : str_view {}; #elif defined(__clang__) str_view name; if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) { - static_assert( - always_false_v, "magic_enum::detail::n requires __PRETTY_FUNCTION__." - ); + static_assert(always_false_v, "magic_enum::detail::n requires __PRETTY_FUNCTION__."); return str_view {}; } else { name.size_ = sizeof(__PRETTY_FUNCTION__) - 36; @@ -579,16 +558,13 @@ namespace magic_enum { name.size_ -= 23; name.str_ += 23; } - if (name.str_[0] == '(' || name.str_[0] == '-' || - (name.str_[0] >= '0' && name.str_[0] <= '9')) { + if (name.str_[0] == '(' || name.str_[0] == '-' || (name.str_[0] >= '0' && name.str_[0] <= '9')) { name = str_view {}; } #elif defined(__GNUC__) auto name = str_view { __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1 }; if constexpr (sizeof(__PRETTY_FUNCTION__) == sizeof(__FUNCTION__)) { - static_assert( - always_false_v, "magic_enum::detail::n requires __PRETTY_FUNCTION__." - ); + static_assert(always_false_v, "magic_enum::detail::n requires __PRETTY_FUNCTION__."); return str_view {}; } else if (name.str_[name.size_ - 1] == ']') { name.size_ -= 55; @@ -640,8 +616,7 @@ namespace magic_enum { #if defined(MAGIC_ENUM_GET_ENUM_NAME_BUILTIN) constexpr auto name_ptr = MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V); - auto name = - name_ptr ? str_view { name_ptr, std::char_traits::length(name_ptr) } : str_view {}; + auto name = name_ptr ? str_view { name_ptr, std::char_traits::length(name_ptr) } : str_view {}; #else // CLI/C++ workaround (see https://github.com/Neargye/magic_enum/issues/284). str_view name; @@ -658,8 +633,7 @@ namespace magic_enum { name.size_ -= p; name.str_ += p; } - if (name.str_[0] == '(' || name.str_[0] == '-' || - (name.str_[0] >= '0' && name.str_[0] <= '9')) { + if (name.str_[0] == '(' || name.str_[0] == '-' || (name.str_[0] >= '0' && name.str_[0] <= '9')) { name = str_view {}; } return name; @@ -775,32 +749,29 @@ namespace magic_enum { } } -#define MAGIC_ENUM_FOR_EACH_256(T) \ - T(0) \ - T(1) T(2) T(3) T(4) T(5) T(6) T(7) T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15) T(16) T(17) \ - T(18) T(19) T(20) T(21) T(22) T(23) T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31) T(32) \ - T(33) T(34) T(35) T(36) T(37) T(38) T(39) T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47) \ - T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55) T(56) T(57) T(58) T(59) T(60) T(61) T(62) \ - T(63) T(64) T(65) T(66) T(67) T(68) T(69) T(70) T(71) T(72) T(73) T(74) T(75) T(76) \ - T(77) T(78) T(79) T(80) T(81) T(82) T(83) T(84) T(85) T(86) T(87) T(88) T(89) T(90) \ - T(91) T(92) T(93) T(94) T(95) T(96) T(97) T(98) T(99) T(100) T(101) T(102) T(103) \ - T(104) T(105) T(106) T(107) T(108) T(109) T(110) T(111) T(112) T(113) T(114) \ - T(115) T(116) T(117) T(118) T(119) T(120) T(121) T(122) T(123) T(124) T(125) \ - T(126) T(127) T(128) T(129) T(130) T(131) T(132) T(133) T(134) T(135) T(136) \ - T(137) T(138) T(139) T(140) T(141) T(142) T(143) T(144) T(145) T(146) T(147) \ - T(148) T(149) T(150) T(151) T(152) T(153) T(154) T(155) T(156) T(157) \ - T(158) T(159) T(160) T(161) T(162) T(163) T(164) T(165) T(166) T(167) \ - T(168) T(169) T(170) T(171) T(172) T(173) T(174) T(175) T(176) T(177) \ - T(178) T(179) T(180) T(181) T(182) T(183) T(184) T(185) T(186) \ - T(187) T(188) T(189) T(190) T(191) T(192) T(193) T(194) T(195) \ - T(196) T(197) T(198) T(199) T(200) T(201) T(202) T(203) T(204) \ - T(205) T(206) T(207) T(208) T(209) T(210) T(211) T(212) T(213) \ - T(214) T(215) T(216) T(217) T(218) T(219) T(220) T(221) \ - T(222) T(223) T(224) T(225) T(226) T(227) T(228) T(229) \ - T(230) T(231) T(232) T(233) T(234) T(235) T(236) T(237) \ - T(238) T(239) T(240) T(241) T(242) T(243) T(244) \ - T(245) T(246) T(247) T(248) T(249) T(250) T(251) \ - T(252) T(253) T(254) T(255) +#define MAGIC_ENUM_FOR_EACH_256(T) \ + T(0) \ + T(1) \ + T(2) T(3) T(4) T(5) T(6) T(7) T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15) T(16) T(17) T(18) T(19) T(20) \ + T(21) T(22) T(23) T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31) T(32) T(33) T(34) T(35) T(36) T(37) \ + T(38) T(39) T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47) T(48) T(49) T(50) T(51) T(52) T(53) T(54) \ + T(55) T(56) T(57) T(58) T(59) T(60) T(61) T(62) T(63) T(64) T(65) T(66) T(67) T(68) T(69) T(70) \ + T(71) T(72) T(73) T(74) T(75) T(76) T(77) T(78) T(79) T(80) T(81) T(82) T(83) T(84) T(85) T(86) \ + T(87) T(88) T(89) T(90) T(91) T(92) T(93) T(94) T(95) T(96) T(97) T(98) T(99) T(100) T(101) \ + T(102) T(103) T(104) T(105) T(106) T(107) T(108) T(109) T(110) T(111) T(112) T(113) T(114) \ + T(115) T(116) T(117) T(118) T(119) T(120) T(121) T(122) T(123) T(124) T(125) T(126) T(127) \ + T(128) T(129) T(130) T(131) T(132) T(133) T(134) T(135) T(136) T(137) T(138) T(139) T(140) \ + T(141) T(142) T(143) T(144) T(145) T(146) T(147) T(148) T(149) T(150) T(151) T(152) \ + T(153) T(154) T(155) T(156) T(157) T(158) T(159) T(160) T(161) T(162) T(163) T(164) \ + T(165) T(166) T(167) T(168) T(169) T(170) T(171) T(172) T(173) T(174) T(175) T(176) \ + T(177) T(178) T(179) T(180) T(181) T(182) T(183) T(184) T(185) T(186) T(187) \ + T(188) T(189) T(190) T(191) T(192) T(193) T(194) T(195) T(196) T(197) T(198) \ + T(199) T(200) T(201) T(202) T(203) T(204) T(205) T(206) T(207) T(208) T(209) \ + T(210) T(211) T(212) T(213) T(214) T(215) T(216) T(217) T(218) T(219) T(220) \ + T(221) T(222) T(223) T(224) T(225) T(226) T(227) T(228) T(229) T(230) \ + T(231) T(232) T(233) T(234) T(235) T(236) T(237) T(238) T(239) T(240) \ + T(241) T(242) T(243) T(244) T(245) T(246) T(247) T(248) T(249) T(250) \ + T(251) T(252) T(253) T(254) T(255) template constexpr void valid_count(bool* valid, std::size_t& count) noexcept { @@ -913,12 +884,10 @@ namespace magic_enum { inline constexpr auto count_v = values_v.size(); template > - inline constexpr auto min_v = - (count_v > 0) ? static_cast(values_v.front()) : U { 0 }; + inline constexpr auto min_v = (count_v > 0) ? static_cast(values_v.front()) : U { 0 }; template > - inline constexpr auto max_v = - (count_v > 0) ? static_cast(values_v.back()) : U { 0 }; + inline constexpr auto max_v = (count_v > 0) ? static_cast(values_v.back()) : U { 0 }; template constexpr auto names(std::index_sequence) noexcept { @@ -1094,9 +1063,8 @@ namespace magic_enum { constexpr std::uint32_t operator()(string_view value) const noexcept { auto acc = static_cast(2166136261ULL); for (const auto c : value) { - acc = - ((acc ^ static_cast(c)) * static_cast(16777619ULL)) & - (std::numeric_limits::max)(); + acc = ((acc ^ static_cast(c)) * static_cast(16777619ULL)) & + (std::numeric_limits::max)(); } return static_cast(acc); } @@ -1140,8 +1108,7 @@ namespace magic_enum { } template - constexpr R - invoke_r(F&& f, Args&&... args) noexcept(std::is_nothrow_invocable_r_v) { + constexpr R invoke_r(F&& f, Args&&... args) noexcept(std::is_nothrow_invocable_r_v) { if constexpr (std::is_void_v) { std::forward(f)(std::forward(args)...); } else { @@ -1181,47 +1148,41 @@ namespace magic_enum { return true; } -#define MAGIC_ENUM_CASE(val) \ - case cases[val]: \ - if constexpr ((val) + Page < size) { \ - if (!pred(values[val + Page], searched)) { \ - break; \ - } \ - if constexpr (CallValue == case_call_t::index) { \ - if constexpr (std::is_invocable_r_v< \ - result_t, \ - Lambda, \ - std::integral_constant>) { \ - return detail::invoke_r( \ - std::forward(lambda), std::integral_constant {} \ - ); \ - } else if constexpr (std::is_invocable_v< \ - Lambda, \ - std::integral_constant>) { \ - MAGIC_ENUM_ASSERT(false && "magic_enum::detail::constexpr_switch wrong result type."); \ - } \ - } else if constexpr (CallValue == case_call_t::value) { \ - if constexpr (std:: \ - is_invocable_r_v>) { \ - return detail::invoke_r( \ - std::forward(lambda), enum_constant {} \ - ); \ - } else if constexpr (std::is_invocable_r_v< \ - result_t, \ - Lambda, \ - enum_constant>) { \ - MAGIC_ENUM_ASSERT(false && "magic_enum::detail::constexpr_switch wrong result type."); \ - } \ - } \ - break; \ - } else \ +#define MAGIC_ENUM_CASE(val) \ + case cases[val]: \ + if constexpr ((val) + Page < size) { \ + if (!pred(values[val + Page], searched)) { \ + break; \ + } \ + if constexpr (CallValue == case_call_t::index) { \ + if constexpr (std::is_invocable_r_v< \ + result_t, \ + Lambda, \ + std::integral_constant>) { \ + return detail::invoke_r( \ + std::forward(lambda), std::integral_constant {} \ + ); \ + } else if constexpr (std::is_invocable_v>) { \ + MAGIC_ENUM_ASSERT(false && "magic_enum::detail::constexpr_switch wrong result type."); \ + } \ + } else if constexpr (CallValue == case_call_t::value) { \ + if constexpr (std::is_invocable_r_v>) { \ + return detail::invoke_r( \ + std::forward(lambda), enum_constant {} \ + ); \ + } else if constexpr (std::is_invocable_r_v>) { \ + MAGIC_ENUM_ASSERT(false && "magic_enum::detail::constexpr_switch wrong result type."); \ + } \ + } \ + break; \ + } else \ [[fallthrough]]; template < auto* GlobValues, case_call_t CallValue, - std::size_t Page = 0, - typename Hash = constexpr_hash_t::value_type>, + std::size_t Page = 0, + typename Hash = constexpr_hash_t::value_type>, typename BinaryPredicate = std::equal_to<>, typename Lambda, typename ResultGetterType> @@ -1328,8 +1289,8 @@ namespace magic_enum { if constexpr (detail::is_sparse_v) { return MAGIC_ENUM_ASSERT(index < detail::count_v), detail::values_v[index]; } else { - constexpr auto min = (S == detail::enum_subtype::flags) ? detail::log2(detail::min_v) - : detail::min_v; + constexpr auto min = + (S == detail::enum_subtype::flags) ? detail::log2(detail::min_v) : detail::min_v; return MAGIC_ENUM_ASSERT(index < detail::count_v), detail::value(index); } @@ -1349,8 +1310,7 @@ namespace magic_enum { // Returns std::array with enum values, sorted by enum value. template > - [[nodiscard]] constexpr auto enum_values() noexcept - -> detail::enable_if_t> { + [[nodiscard]] constexpr auto enum_values() noexcept -> detail::enable_if_t> { using D = std::decay_t; static_assert( detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min." @@ -1376,8 +1336,7 @@ namespace magic_enum { // Obtains index in enum values from enum value. // Returns optional with index. template > - [[nodiscard]] constexpr auto enum_index(E value - ) noexcept -> detail::enable_if_t> { + [[nodiscard]] constexpr auto enum_index(E value) noexcept -> detail::enable_if_t> { using D = std::decay_t; using U = underlying_type_t; static_assert( @@ -1410,8 +1369,7 @@ namespace magic_enum { // Obtains index in enum values from enum value. // Returns optional with index. template - [[nodiscard]] constexpr auto enum_index(E value - ) noexcept -> detail::enable_if_t> { + [[nodiscard]] constexpr auto enum_index(E value) noexcept -> detail::enable_if_t> { using D = std::decay_t; static_assert( detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min." @@ -1422,8 +1380,7 @@ namespace magic_enum { // Obtains index in enum values from static storage enum variable. template >> - [[nodiscard]] constexpr auto enum_index() noexcept - -> detail::enable_if_t { + [[nodiscard]] constexpr auto enum_index() noexcept -> detail::enable_if_t { using D = std::decay_t; static_assert( detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min." @@ -1438,8 +1395,7 @@ namespace magic_enum { // This version is much lighter on the compile times and is not restricted to the enum_range // limitation. template - [[nodiscard]] constexpr auto enum_name() noexcept - -> detail::enable_if_t { + [[nodiscard]] constexpr auto enum_name() noexcept -> detail::enable_if_t { constexpr string_view name = detail::enum_name_v, V>; static_assert(!name.empty(), "magic_enum::enum_name enum value does not have a name."); @@ -1475,8 +1431,7 @@ namespace magic_enum { // Returns std::array with names, sorted by enum value. template > - [[nodiscard]] constexpr auto enum_names() noexcept - -> detail::enable_if_t> { + [[nodiscard]] constexpr auto enum_names() noexcept -> detail::enable_if_t> { using D = std::decay_t; static_assert( detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min." @@ -1487,8 +1442,7 @@ namespace magic_enum { // Returns std::array with pairs (value, name), sorted by enum value. template > - [[nodiscard]] constexpr auto enum_entries() noexcept - -> detail::enable_if_t> { + [[nodiscard]] constexpr auto enum_entries() noexcept -> detail::enable_if_t> { using D = std::decay_t; static_assert( detail::is_reflected_v, "magic_enum requires enum implementation and valid max and min." @@ -1538,10 +1492,8 @@ namespace magic_enum { typename E, detail::enum_subtype S = detail::subtype_v, typename BinaryPredicate = std::equal_to<>> - [[nodiscard]] constexpr auto enum_cast( - string_view value, - [[maybe_unused]] BinaryPredicate p = {} - ) noexcept(detail::is_nothrow_invocable() + [[nodiscard]] constexpr auto enum_cast(string_view value, [[maybe_unused]] BinaryPredicate p = {}) noexcept( + detail::is_nothrow_invocable() ) -> detail::enable_if_t>, BinaryPredicate> { using D = std::decay_t; static_assert( @@ -1638,12 +1590,10 @@ namespace magic_enum { } template - inline constexpr auto as_flags = - AsFlags ? detail::enum_subtype::flags : detail::enum_subtype::common; + inline constexpr auto as_flags = AsFlags ? detail::enum_subtype::flags : detail::enum_subtype::common; template - inline constexpr auto as_common = - AsFlags ? detail::enum_subtype::common : detail::enum_subtype::flags; + inline constexpr auto as_common = AsFlags ? detail::enum_subtype::common : detail::enum_subtype::flags; namespace bitwise_operators { @@ -1654,23 +1604,17 @@ namespace magic_enum { template = 0> constexpr E operator|(E lhs, E rhs) noexcept { - return static_cast( - static_cast>(lhs) | static_cast>(rhs) - ); + return static_cast(static_cast>(lhs) | static_cast>(rhs)); } template = 0> constexpr E operator&(E lhs, E rhs) noexcept { - return static_cast( - static_cast>(lhs) & static_cast>(rhs) - ); + return static_cast(static_cast>(lhs) & static_cast>(rhs)); } template = 0> constexpr E operator^(E lhs, E rhs) noexcept { - return static_cast( - static_cast>(lhs) ^ static_cast>(rhs) - ); + return static_cast(static_cast>(lhs) ^ static_cast>(rhs)); } template = 0>