From 1075096d8ca7519873c7473a6ef1d285b01a9c84 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Wed, 17 Jun 2020 16:20:23 +0200 Subject: [PATCH] Introduce cast-operator to std::string and std::string_view on ArrayWrapper1D -> needed to add all the relational operators on as well to keep the compiler happy! --- VulkanHppGenerator.cpp | 74 +++++++++++++++++++++++++++++++++++++++++- vulkan/vulkan.hpp | 74 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 146 insertions(+), 2 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 1bdf6ad..c5bdde6 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -6940,6 +6940,56 @@ int main( int argc, char ** argv ) { return this->data(); } + + template ::value, int>::type = 0> + operator std::string const () const VULKAN_HPP_NOEXCEPT + { + return std::string( this->data() ); + } + +#if 17 <= VULKAN_HPP_CPP_VERSION + template ::value, int>::type = 0> + operator std::string_view const () const VULKAN_HPP_NOEXCEPT + { + return std::string_view( this->data() ); + } +#endif + + template ::value, int>::type = 0> + bool operator<( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) < *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator<=( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) <= *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator>( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) > *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator>=( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) >= *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator==( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) == *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator!=( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) != *static_cast const *>( &rhs ); + } }; // specialization of relational operators between std::string and arrays of chars @@ -7758,7 +7808,7 @@ int main( int argc, char ** argv ) # endif #endif -#if __cplusplus >= 201402L +#if 14 <= VULKAN_HPP_CPP_VERSION # define VULKAN_HPP_DEPRECATED( msg ) [[deprecated( msg )]] #else # define VULKAN_HPP_DEPRECATED( msg ) @@ -7842,6 +7892,24 @@ int main( int argc, char ** argv ) #ifndef VULKAN_HPP #define VULKAN_HPP +#if defined( _MSVC_LANG ) +# define VULKAN_HPP_CPLUSPLUS _MSVC_LANG +#else +# define VULKAN_HPP_CPLUSPLUS __cplusplus +#endif + +#if VULKAN_HPP_CPLUSPLUS < 201103L +static_assert( false, "vulkan.hpp needs at least c++ standard version 11" ); +#elif VULKAN_HPP_CPLUSPLUS < 201402L +# define VULKAN_HPP_CPP_VERSION 11 +#elif VULKAN_HPP_CPLUSPLUS < 201703L +# define VULKAN_HPP_CPP_VERSION 14 +#elif VULKAN_HPP_CPLUSPLUS < 202002L +# define VULKAN_HPP_CPP_VERSION 17 +#else +# define VULKAN_HPP_CPP_VERSION 20 +#endif + #include #include #include @@ -7855,6 +7923,10 @@ int main( int argc, char ** argv ) #include #include +#if 17 <= VULKAN_HPP_CPP_VERSION +#include +#endif + #if defined(VULKAN_HPP_DISABLE_ENHANCED_MODE) # if !defined(VULKAN_HPP_NO_SMART_HANDLE) # define VULKAN_HPP_NO_SMART_HANDLE diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index f280a47..771396f 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -8,6 +8,24 @@ #ifndef VULKAN_HPP #define VULKAN_HPP +#if defined( _MSVC_LANG ) +# define VULKAN_HPP_CPLUSPLUS _MSVC_LANG +#else +# define VULKAN_HPP_CPLUSPLUS __cplusplus +#endif + +#if VULKAN_HPP_CPLUSPLUS < 201103L +static_assert( false, "vulkan.hpp needs at least c++ standard version 11" ); +#elif VULKAN_HPP_CPLUSPLUS < 201402L +# define VULKAN_HPP_CPP_VERSION 11 +#elif VULKAN_HPP_CPLUSPLUS < 201703L +# define VULKAN_HPP_CPP_VERSION 14 +#elif VULKAN_HPP_CPLUSPLUS < 202002L +# define VULKAN_HPP_CPP_VERSION 17 +#else +# define VULKAN_HPP_CPP_VERSION 20 +#endif + #include #include #include @@ -21,6 +39,10 @@ #include #include +#if 17 <= VULKAN_HPP_CPP_VERSION +# include +#endif + #if defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) # if !defined( VULKAN_HPP_NO_SMART_HANDLE ) # define VULKAN_HPP_NO_SMART_HANDLE @@ -141,7 +163,7 @@ static_assert( VK_HEADER_VERSION == 144, "Wrong VK_HEADER_VERSION!" ); # endif #endif -#if __cplusplus >= 201402L +#if 14 <= VULKAN_HPP_CPP_VERSION # define VULKAN_HPP_DEPRECATED( msg ) [[deprecated( msg )]] #else # define VULKAN_HPP_DEPRECATED( msg ) @@ -341,6 +363,56 @@ namespace VULKAN_HPP_NAMESPACE { return this->data(); } + + template ::value, int>::type = 0> + operator std::string const() const VULKAN_HPP_NOEXCEPT + { + return std::string( this->data() ); + } + +#if 17 <= VULKAN_HPP_CPP_VERSION + template ::value, int>::type = 0> + operator std::string_view const() const VULKAN_HPP_NOEXCEPT + { + return std::string_view( this->data() ); + } +#endif + + template ::value, int>::type = 0> + bool operator<( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) < *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator<=( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) <= *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator>( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) > *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator>=( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) >= *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator==( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) == *static_cast const *>( &rhs ); + } + + template ::value, int>::type = 0> + bool operator!=( ArrayWrapper1D const & rhs ) const VULKAN_HPP_NOEXCEPT + { + return *static_cast const *>( this ) != *static_cast const *>( &rhs ); + } }; // specialization of relational operators between std::string and arrays of chars