Scope operator for partial template specialization

Hi,

Got a quick question. Let's say I have the following shell of a template and a partial specialization of that template:

1
2
3
4
5
6
7
8
9
10
11
template<typename T, int param> class tmpl {
    public:
        // members
};
//partial template specialization
template<int param> class tmpl<double,param> {
    public:
        // members
        tmpl();
};

I would like to define the constructor for the specialized template outside of the template prototype using the scope operator. What syntax is required to access this member?

Thanks in advance...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

template<typename T, int param> class tmpl {
    public:
        tmpl() {
            std::cout << "template constructor" << std::endl;
        }
};

template<int param> class tmpl<double,param> {
    public:
        tmpl();
};

template <int param>
tmpl<double,param>::tmpl() {
    std::cout << "specialization constructor" << std::endl;
}

int main() {
    tmpl<int,1> asdf;
    tmpl<double,2> zxcv;

    std::cin.get();
    return 0;
}
Last edited on
Excellent; many thanks...
Topic archived. No new replies allowed.