Correct way of calling VSTPluginFormat::dispatcher

I am writing a VST3 plugin that hosts a VST2 plugin and need to call the dispatcher.

class MyPluginAudioProcessor : public juce::AudioProcessor, public juce::AudioProcessorListener

std::unique_ptr <juce::AudioPluginInstance> vst2plugin;

I get an compiler error:
*Cannot use dynamic_cast to convert from 'std::unique_ptr<juce::AudioPluginInstance>’ to 'juce::AudioPluginInstance

void MyPluginAudioProcessor::foo()
auto* XXX= dynamic_cast<juce::AudioPluginInstance*>(this.vst2plugin);
juce::VSTPluginFormat::dispatcher(XXX, 0, 0, 0, nullptr, 0);

dynamic_cast is not the right tool to access the pointee of an unique_ptr.

Since the vst2plugin is a std::unique_ptr<juce::AudioPluginInstance>, you would access the juce::AudioPluginInstance* by calling vst2plugin.get(), or to get the reference juce::AudioPluginInstance& by dereferencing it *vst2plugin. But careful, if it is a nullptr.

Thanks a lot Daniel!
vst2plugin.get() did do the trick