From 9004069b9b235ca1e3b642a6349c7d336fe2ee06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Thu, 7 Sep 2023 18:42:46 +0200 Subject: [PATCH] Move Flags<> and FlagTraits<> from vulkan.hpp to vulkan_enums.hpp (#1654) --- VulkanHppGenerator.cpp | 5 +- vulkan/vulkan.hpp | 206 -------------------------------------- vulkan/vulkan_enums.hpp | 206 ++++++++++++++++++++++++++++++++++++++ vulkan/vulkansc.hpp | 206 -------------------------------------- vulkan/vulkansc_enums.hpp | 206 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 415 insertions(+), 414 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index b811668..e1ec0ec 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -113,6 +113,8 @@ void VulkanHppGenerator::generateEnumsHppFile() const namespace VULKAN_HPP_NAMESPACE { +${Flags} + template struct CppType {}; @@ -125,6 +127,7 @@ ${objectTypeToDebugReportObjectType} std::string str = replaceWithMap( vulkanEnumsHppTemplate, { { "enums", generateEnums() }, + { "Flags", readSnippet( "Flags.hpp" ) }, { "indexTypeTraits", generateIndexTypeTraits() }, { "licenseHeader", m_vulkanLicenseHeader }, { "objectTypeToDebugReportObjectType", generateObjectTypeToDebugReportObjectType() } } ); @@ -454,7 +457,6 @@ namespace VULKAN_HPP_NAMESPACE { ${ArrayWrapper1D} ${ArrayWrapper2D} -${Flags} #if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) ${ArrayProxy} ${ArrayProxyNoTemporaries} @@ -535,7 +537,6 @@ ${DispatchLoaderDynamic} { "DispatchLoaderStatic", generateDispatchLoaderStatic() }, { "DynamicLoader", readSnippet( "DynamicLoader.hpp" ) }, { "Exceptions", readSnippet( "Exceptions.hpp" ) }, - { "Flags", readSnippet( "Flags.hpp" ) }, { "headerVersion", m_version }, { "includes", replaceWithMap( readSnippet( "includes.hpp" ), { { "vulkan_h", ( m_api == "vulkan" ) ? "vulkan.h" : "vulkan_sc_core.h" } } ) }, { "licenseHeader", m_vulkanLicenseHeader }, diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index b9b60e1..5e1f4c9 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -225,212 +225,6 @@ namespace VULKAN_HPP_NAMESPACE } }; - template - struct FlagTraits - { - static VULKAN_HPP_CONST_OR_CONSTEXPR bool isBitmask = false; - }; - - template - class Flags - { - public: - using MaskType = typename std::underlying_type::type; - - // constructors - VULKAN_HPP_CONSTEXPR Flags() VULKAN_HPP_NOEXCEPT : m_mask( 0 ) {} - - VULKAN_HPP_CONSTEXPR Flags( BitType bit ) VULKAN_HPP_NOEXCEPT : m_mask( static_cast( bit ) ) {} - - VULKAN_HPP_CONSTEXPR Flags( Flags const & rhs ) VULKAN_HPP_NOEXCEPT = default; - - VULKAN_HPP_CONSTEXPR explicit Flags( MaskType flags ) VULKAN_HPP_NOEXCEPT : m_mask( flags ) {} - - // relational operators -#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) - auto operator<=>( Flags const & ) const = default; -#else - VULKAN_HPP_CONSTEXPR bool operator<( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask < rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator<=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask <= rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator>( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask > rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator>=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask >= rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator==( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask == rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator!=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask != rhs.m_mask; - } -#endif - - // logical operator - VULKAN_HPP_CONSTEXPR bool operator!() const VULKAN_HPP_NOEXCEPT - { - return !m_mask; - } - - // bitwise operators - VULKAN_HPP_CONSTEXPR Flags operator&( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return Flags( m_mask & rhs.m_mask ); - } - - VULKAN_HPP_CONSTEXPR Flags operator|( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return Flags( m_mask | rhs.m_mask ); - } - - VULKAN_HPP_CONSTEXPR Flags operator^( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return Flags( m_mask ^ rhs.m_mask ); - } - - VULKAN_HPP_CONSTEXPR Flags operator~() const VULKAN_HPP_NOEXCEPT - { - return Flags( m_mask ^ FlagTraits::allFlags.m_mask ); - } - - // assignment operators - VULKAN_HPP_CONSTEXPR_14 Flags & operator=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT = default; - - VULKAN_HPP_CONSTEXPR_14 Flags & operator|=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT - { - m_mask |= rhs.m_mask; - return *this; - } - - VULKAN_HPP_CONSTEXPR_14 Flags & operator&=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT - { - m_mask &= rhs.m_mask; - return *this; - } - - VULKAN_HPP_CONSTEXPR_14 Flags & operator^=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT - { - m_mask ^= rhs.m_mask; - return *this; - } - - // cast operators - explicit VULKAN_HPP_CONSTEXPR operator bool() const VULKAN_HPP_NOEXCEPT - { - return !!m_mask; - } - - explicit VULKAN_HPP_CONSTEXPR operator MaskType() const VULKAN_HPP_NOEXCEPT - { - return m_mask; - } - -#if defined( VULKAN_HPP_FLAGS_MASK_TYPE_AS_PUBLIC ) - public: -#else - private: -#endif - MaskType m_mask; - }; - -#if !defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) - // relational operators only needed for pre C++20 - template - VULKAN_HPP_CONSTEXPR bool operator<( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator>( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator<=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator>=( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator>( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator<( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator>=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator<=( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator==( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator==( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator!=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator!=( bit ); - } -#endif - - // bitwise operators - template - VULKAN_HPP_CONSTEXPR Flags operator&( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator&( bit ); - } - - template - VULKAN_HPP_CONSTEXPR Flags operator|( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator|( bit ); - } - - template - VULKAN_HPP_CONSTEXPR Flags operator^( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator^( bit ); - } - - // bitwise operators on BitType - template ::isBitmask, bool>::type = true> - VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator&( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT - { - return Flags( lhs ) & rhs; - } - - template ::isBitmask, bool>::type = true> - VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator|( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT - { - return Flags( lhs ) | rhs; - } - - template ::isBitmask, bool>::type = true> - VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator^( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT - { - return Flags( lhs ) ^ rhs; - } - - template ::isBitmask, bool>::type = true> - VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator~( BitType bit ) VULKAN_HPP_NOEXCEPT - { - return ~( Flags( bit ) ); - } - #if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) template class ArrayProxy diff --git a/vulkan/vulkan_enums.hpp b/vulkan/vulkan_enums.hpp index 1289e1d..08c7c6b 100644 --- a/vulkan/vulkan_enums.hpp +++ b/vulkan/vulkan_enums.hpp @@ -10,6 +10,212 @@ namespace VULKAN_HPP_NAMESPACE { + template + struct FlagTraits + { + static VULKAN_HPP_CONST_OR_CONSTEXPR bool isBitmask = false; + }; + + template + class Flags + { + public: + using MaskType = typename std::underlying_type::type; + + // constructors + VULKAN_HPP_CONSTEXPR Flags() VULKAN_HPP_NOEXCEPT : m_mask( 0 ) {} + + VULKAN_HPP_CONSTEXPR Flags( BitType bit ) VULKAN_HPP_NOEXCEPT : m_mask( static_cast( bit ) ) {} + + VULKAN_HPP_CONSTEXPR Flags( Flags const & rhs ) VULKAN_HPP_NOEXCEPT = default; + + VULKAN_HPP_CONSTEXPR explicit Flags( MaskType flags ) VULKAN_HPP_NOEXCEPT : m_mask( flags ) {} + + // relational operators +#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) + auto operator<=>( Flags const & ) const = default; +#else + VULKAN_HPP_CONSTEXPR bool operator<( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask < rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator<=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask <= rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator>( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask > rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator>=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask >= rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator==( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask == rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator!=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask != rhs.m_mask; + } +#endif + + // logical operator + VULKAN_HPP_CONSTEXPR bool operator!() const VULKAN_HPP_NOEXCEPT + { + return !m_mask; + } + + // bitwise operators + VULKAN_HPP_CONSTEXPR Flags operator&( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return Flags( m_mask & rhs.m_mask ); + } + + VULKAN_HPP_CONSTEXPR Flags operator|( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return Flags( m_mask | rhs.m_mask ); + } + + VULKAN_HPP_CONSTEXPR Flags operator^( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return Flags( m_mask ^ rhs.m_mask ); + } + + VULKAN_HPP_CONSTEXPR Flags operator~() const VULKAN_HPP_NOEXCEPT + { + return Flags( m_mask ^ FlagTraits::allFlags.m_mask ); + } + + // assignment operators + VULKAN_HPP_CONSTEXPR_14 Flags & operator=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT = default; + + VULKAN_HPP_CONSTEXPR_14 Flags & operator|=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT + { + m_mask |= rhs.m_mask; + return *this; + } + + VULKAN_HPP_CONSTEXPR_14 Flags & operator&=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT + { + m_mask &= rhs.m_mask; + return *this; + } + + VULKAN_HPP_CONSTEXPR_14 Flags & operator^=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT + { + m_mask ^= rhs.m_mask; + return *this; + } + + // cast operators + explicit VULKAN_HPP_CONSTEXPR operator bool() const VULKAN_HPP_NOEXCEPT + { + return !!m_mask; + } + + explicit VULKAN_HPP_CONSTEXPR operator MaskType() const VULKAN_HPP_NOEXCEPT + { + return m_mask; + } + +#if defined( VULKAN_HPP_FLAGS_MASK_TYPE_AS_PUBLIC ) + public: +#else + private: +#endif + MaskType m_mask; + }; + +#if !defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) + // relational operators only needed for pre C++20 + template + VULKAN_HPP_CONSTEXPR bool operator<( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator>( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator<=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator>=( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator>( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator<( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator>=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator<=( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator==( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator==( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator!=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator!=( bit ); + } +#endif + + // bitwise operators + template + VULKAN_HPP_CONSTEXPR Flags operator&( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator&( bit ); + } + + template + VULKAN_HPP_CONSTEXPR Flags operator|( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator|( bit ); + } + + template + VULKAN_HPP_CONSTEXPR Flags operator^( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator^( bit ); + } + + // bitwise operators on BitType + template ::isBitmask, bool>::type = true> + VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator&( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT + { + return Flags( lhs ) & rhs; + } + + template ::isBitmask, bool>::type = true> + VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator|( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT + { + return Flags( lhs ) | rhs; + } + + template ::isBitmask, bool>::type = true> + VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator^( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT + { + return Flags( lhs ) ^ rhs; + } + + template ::isBitmask, bool>::type = true> + VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator~( BitType bit ) VULKAN_HPP_NOEXCEPT + { + return ~( Flags( bit ) ); + } + template struct CppType { diff --git a/vulkan/vulkansc.hpp b/vulkan/vulkansc.hpp index 417e73e..8c6a433 100644 --- a/vulkan/vulkansc.hpp +++ b/vulkan/vulkansc.hpp @@ -225,212 +225,6 @@ namespace VULKAN_HPP_NAMESPACE } }; - template - struct FlagTraits - { - static VULKAN_HPP_CONST_OR_CONSTEXPR bool isBitmask = false; - }; - - template - class Flags - { - public: - using MaskType = typename std::underlying_type::type; - - // constructors - VULKAN_HPP_CONSTEXPR Flags() VULKAN_HPP_NOEXCEPT : m_mask( 0 ) {} - - VULKAN_HPP_CONSTEXPR Flags( BitType bit ) VULKAN_HPP_NOEXCEPT : m_mask( static_cast( bit ) ) {} - - VULKAN_HPP_CONSTEXPR Flags( Flags const & rhs ) VULKAN_HPP_NOEXCEPT = default; - - VULKAN_HPP_CONSTEXPR explicit Flags( MaskType flags ) VULKAN_HPP_NOEXCEPT : m_mask( flags ) {} - - // relational operators -#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) - auto operator<=>( Flags const & ) const = default; -#else - VULKAN_HPP_CONSTEXPR bool operator<( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask < rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator<=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask <= rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator>( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask > rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator>=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask >= rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator==( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask == rhs.m_mask; - } - - VULKAN_HPP_CONSTEXPR bool operator!=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return m_mask != rhs.m_mask; - } -#endif - - // logical operator - VULKAN_HPP_CONSTEXPR bool operator!() const VULKAN_HPP_NOEXCEPT - { - return !m_mask; - } - - // bitwise operators - VULKAN_HPP_CONSTEXPR Flags operator&( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return Flags( m_mask & rhs.m_mask ); - } - - VULKAN_HPP_CONSTEXPR Flags operator|( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return Flags( m_mask | rhs.m_mask ); - } - - VULKAN_HPP_CONSTEXPR Flags operator^( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT - { - return Flags( m_mask ^ rhs.m_mask ); - } - - VULKAN_HPP_CONSTEXPR Flags operator~() const VULKAN_HPP_NOEXCEPT - { - return Flags( m_mask ^ FlagTraits::allFlags.m_mask ); - } - - // assignment operators - VULKAN_HPP_CONSTEXPR_14 Flags & operator=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT = default; - - VULKAN_HPP_CONSTEXPR_14 Flags & operator|=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT - { - m_mask |= rhs.m_mask; - return *this; - } - - VULKAN_HPP_CONSTEXPR_14 Flags & operator&=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT - { - m_mask &= rhs.m_mask; - return *this; - } - - VULKAN_HPP_CONSTEXPR_14 Flags & operator^=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT - { - m_mask ^= rhs.m_mask; - return *this; - } - - // cast operators - explicit VULKAN_HPP_CONSTEXPR operator bool() const VULKAN_HPP_NOEXCEPT - { - return !!m_mask; - } - - explicit VULKAN_HPP_CONSTEXPR operator MaskType() const VULKAN_HPP_NOEXCEPT - { - return m_mask; - } - -#if defined( VULKAN_HPP_FLAGS_MASK_TYPE_AS_PUBLIC ) - public: -#else - private: -#endif - MaskType m_mask; - }; - -#if !defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) - // relational operators only needed for pre C++20 - template - VULKAN_HPP_CONSTEXPR bool operator<( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator>( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator<=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator>=( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator>( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator<( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator>=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator<=( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator==( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator==( bit ); - } - - template - VULKAN_HPP_CONSTEXPR bool operator!=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator!=( bit ); - } -#endif - - // bitwise operators - template - VULKAN_HPP_CONSTEXPR Flags operator&( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator&( bit ); - } - - template - VULKAN_HPP_CONSTEXPR Flags operator|( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator|( bit ); - } - - template - VULKAN_HPP_CONSTEXPR Flags operator^( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT - { - return flags.operator^( bit ); - } - - // bitwise operators on BitType - template ::isBitmask, bool>::type = true> - VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator&( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT - { - return Flags( lhs ) & rhs; - } - - template ::isBitmask, bool>::type = true> - VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator|( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT - { - return Flags( lhs ) | rhs; - } - - template ::isBitmask, bool>::type = true> - VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator^( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT - { - return Flags( lhs ) ^ rhs; - } - - template ::isBitmask, bool>::type = true> - VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator~( BitType bit ) VULKAN_HPP_NOEXCEPT - { - return ~( Flags( bit ) ); - } - #if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) template class ArrayProxy diff --git a/vulkan/vulkansc_enums.hpp b/vulkan/vulkansc_enums.hpp index dcdaa8f..0d3729b 100644 --- a/vulkan/vulkansc_enums.hpp +++ b/vulkan/vulkansc_enums.hpp @@ -10,6 +10,212 @@ namespace VULKAN_HPP_NAMESPACE { + template + struct FlagTraits + { + static VULKAN_HPP_CONST_OR_CONSTEXPR bool isBitmask = false; + }; + + template + class Flags + { + public: + using MaskType = typename std::underlying_type::type; + + // constructors + VULKAN_HPP_CONSTEXPR Flags() VULKAN_HPP_NOEXCEPT : m_mask( 0 ) {} + + VULKAN_HPP_CONSTEXPR Flags( BitType bit ) VULKAN_HPP_NOEXCEPT : m_mask( static_cast( bit ) ) {} + + VULKAN_HPP_CONSTEXPR Flags( Flags const & rhs ) VULKAN_HPP_NOEXCEPT = default; + + VULKAN_HPP_CONSTEXPR explicit Flags( MaskType flags ) VULKAN_HPP_NOEXCEPT : m_mask( flags ) {} + + // relational operators +#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) + auto operator<=>( Flags const & ) const = default; +#else + VULKAN_HPP_CONSTEXPR bool operator<( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask < rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator<=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask <= rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator>( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask > rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator>=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask >= rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator==( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask == rhs.m_mask; + } + + VULKAN_HPP_CONSTEXPR bool operator!=( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return m_mask != rhs.m_mask; + } +#endif + + // logical operator + VULKAN_HPP_CONSTEXPR bool operator!() const VULKAN_HPP_NOEXCEPT + { + return !m_mask; + } + + // bitwise operators + VULKAN_HPP_CONSTEXPR Flags operator&( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return Flags( m_mask & rhs.m_mask ); + } + + VULKAN_HPP_CONSTEXPR Flags operator|( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return Flags( m_mask | rhs.m_mask ); + } + + VULKAN_HPP_CONSTEXPR Flags operator^( Flags const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return Flags( m_mask ^ rhs.m_mask ); + } + + VULKAN_HPP_CONSTEXPR Flags operator~() const VULKAN_HPP_NOEXCEPT + { + return Flags( m_mask ^ FlagTraits::allFlags.m_mask ); + } + + // assignment operators + VULKAN_HPP_CONSTEXPR_14 Flags & operator=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT = default; + + VULKAN_HPP_CONSTEXPR_14 Flags & operator|=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT + { + m_mask |= rhs.m_mask; + return *this; + } + + VULKAN_HPP_CONSTEXPR_14 Flags & operator&=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT + { + m_mask &= rhs.m_mask; + return *this; + } + + VULKAN_HPP_CONSTEXPR_14 Flags & operator^=( Flags const & rhs ) VULKAN_HPP_NOEXCEPT + { + m_mask ^= rhs.m_mask; + return *this; + } + + // cast operators + explicit VULKAN_HPP_CONSTEXPR operator bool() const VULKAN_HPP_NOEXCEPT + { + return !!m_mask; + } + + explicit VULKAN_HPP_CONSTEXPR operator MaskType() const VULKAN_HPP_NOEXCEPT + { + return m_mask; + } + +#if defined( VULKAN_HPP_FLAGS_MASK_TYPE_AS_PUBLIC ) + public: +#else + private: +#endif + MaskType m_mask; + }; + +#if !defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) + // relational operators only needed for pre C++20 + template + VULKAN_HPP_CONSTEXPR bool operator<( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator>( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator<=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator>=( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator>( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator<( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator>=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator<=( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator==( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator==( bit ); + } + + template + VULKAN_HPP_CONSTEXPR bool operator!=( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator!=( bit ); + } +#endif + + // bitwise operators + template + VULKAN_HPP_CONSTEXPR Flags operator&( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator&( bit ); + } + + template + VULKAN_HPP_CONSTEXPR Flags operator|( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator|( bit ); + } + + template + VULKAN_HPP_CONSTEXPR Flags operator^( BitType bit, Flags const & flags ) VULKAN_HPP_NOEXCEPT + { + return flags.operator^( bit ); + } + + // bitwise operators on BitType + template ::isBitmask, bool>::type = true> + VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator&( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT + { + return Flags( lhs ) & rhs; + } + + template ::isBitmask, bool>::type = true> + VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator|( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT + { + return Flags( lhs ) | rhs; + } + + template ::isBitmask, bool>::type = true> + VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator^( BitType lhs, BitType rhs ) VULKAN_HPP_NOEXCEPT + { + return Flags( lhs ) ^ rhs; + } + + template ::isBitmask, bool>::type = true> + VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR Flags operator~( BitType bit ) VULKAN_HPP_NOEXCEPT + { + return ~( Flags( bit ) ); + } + template struct CppType {