I'm trying to use the forward headers to limit the scope of my include of openxr.hpp by only using it in one cpp file.
Normally to do this, you forward declare your classes in the header files and include the full headers in the cpp files.
From the docustring, I would expect to be able to use Unique Handles like a unique ptr.
Template class for holding a handle with unique ownership, much like unique_ptr.
Below is an example, it would work if using an std::unique_ptr because the undefined deleter is referenced in the cpp file and not the header.
A.hpp
#pragma once
#include <openxr/openxr_handles_forward.hpp>
struct A {
A();
virtual ~A();
xr::UniqueInstance m_instance;
};
A.cpp
#include "A.h"
#include <openxr/openxr.hpp>
A::A() = default;
A::~A() = default; // Here the deleter is defined and since it has visibility of openxr.hpp it should be okay
In practice, you get the following errors because the forward header implements functions that need full visibility of the forward declared classes and even holds an instance of the type in question.
openxr/openxr_handles_forward.hpp(140,18): error C2027: use of undefined type 'xr::Instance'
openxr/openxr_handles_forward.hpp(140,32): error C3646: 'getRawHandle': unknown override specifier
openxr/openxr_handles_forward.hpp(151,18): error C2027: use of undefined type 'xr::Instance'
openxr/openxr_handles_forward.hpp(170,8): error C2079: 'xr::UniqueHandle<xr::Instance,xr::DispatchLoaderStatic>::m_value' uses undefined class 'xr::Instance
An awkward workaround is to make m_instance into a std::unique_ptr<xr::UniqueInstance>.
I'm trying to use the forward headers to limit the scope of my include of
openxr.hppby only using it in one cpp file.Normally to do this, you forward declare your classes in the header files and include the full headers in the cpp files.
From the docustring, I would expect to be able to use Unique Handles like a unique ptr.
Below is an example, it would work if using an
std::unique_ptrbecause the undefined deleter is referenced in the cpp file and not the header.A.hpp
A.cpp
In practice, you get the following errors because the forward header implements functions that need full visibility of the forward declared classes and even holds an instance of the type in question.
An awkward workaround is to make
m_instanceinto astd::unique_ptr<xr::UniqueInstance>.