How do I declare an empty variable using a template, then instantiate it in the constructor?

I've got the following code within the private section of a class I call Core:

1
2
3
4
// core.h - variable declarations 
private:
VkDeleter<VkInstance> m_instance{vkDestroyInstance};
VkDeleter<VkDebugReportCallbackEXT>m_callback{m_instance, nullptr};


I'd really like to declare an empty m_callback but start it in the Core Constructor function.

m_instance is in the the same Core class, but DestroyDebugReportCallbackEXT is a static function in VkDebug.

As you can can see, I'm able to fill in the first argument of m_callback since m_instance is the same Core class, but the second argument I pass a nullptr in order to avoid errors.

When I get to the constructor, I try adding the Callback function:

1
2
// core.cpp - Constructor implementation. 
VkDeleter<VkDebugReportCallbackEXT>m_callback{m_instance, VkDebug::DestroyDebugReportCallbackEXT};


..and get no compiler errors, but unfortunately m_callback returns 0, which is not the desired behavior.

Is there any way I can declare m_callback empty in the .h file, and instantiate it in the Class constructor function. m_callback uses a template which I think is noticeable.

Really hope this makes sense, my apologizes if it doesn't, still learning how templates work.
Last edited on
Nevermind, stupid mistake. Need to pass in a reference of the callback:

 
&m_callback


:)
Last edited on
Topic archived. No new replies allowed.