mirror of
https://github.com/KhronosGroup/Vulkan-Hpp
synced 2024-11-25 21:40:04 +00:00
34 lines
624 B
C++
34 lines
624 B
C++
template <typename RefType>
|
|
class Optional
|
|
{
|
|
public:
|
|
Optional( RefType & reference ) VULKAN_HPP_NOEXCEPT
|
|
{
|
|
m_ptr = &reference;
|
|
}
|
|
Optional( RefType * ptr ) VULKAN_HPP_NOEXCEPT
|
|
{
|
|
m_ptr = ptr;
|
|
}
|
|
Optional( std::nullptr_t ) VULKAN_HPP_NOEXCEPT
|
|
{
|
|
m_ptr = nullptr;
|
|
}
|
|
|
|
operator RefType *() const VULKAN_HPP_NOEXCEPT
|
|
{
|
|
return m_ptr;
|
|
}
|
|
RefType const * operator->() const VULKAN_HPP_NOEXCEPT
|
|
{
|
|
return m_ptr;
|
|
}
|
|
explicit operator bool() const VULKAN_HPP_NOEXCEPT
|
|
{
|
|
return !!m_ptr;
|
|
}
|
|
|
|
private:
|
|
RefType * m_ptr;
|
|
};
|