svenevs
svenevs

Reputation: 863

call static template method of template class with class as parameter

There is nothing wrong with static methods of template classes having (i) templates and (ii) the class itself as a parameter, is there? Consider the class

template<class Projection>
struct FrameData {
    // ...
    template <bool devPtr>
    static void allocate(FrameData<Projection> &data) {
        // ... do allocations ...
    }

}

This is declared in the header of file A. Elsewhere in the world, I have something like

template <class Projection>
void some_method(FrameData<Projection> &m_data) {
    FrameData<Projection>::allocate<true>(m_data);
}

I'm ending up with some

error: reference to overloaded function could not be resolved; did you mean to call it?

Elsewhere in this world is technically in a source file with some explicit instantiations going on at the bottom, but I put this all in one file with the same errors. Thank you for any insight, please refrain from shaming me on non-header templates. It wasn't my choice.

Upvotes: 1

Views: 858

Answers (1)

Vittorio Romeo
Vittorio Romeo

Reputation: 93384

Is there some sort of analagous .template magic for static methods like the answer here?

Yes.

template <class Projection>
void some_method(FrameData<Projection> &m_data) {
    FrameData<Projection>::template allocate<true>(m_data);
}

Upvotes: 7

Related Questions