template specification without definition

Viewed 64

I have the following code

template <typename Signature>
class Holder;

template <typename I, typename O>
struct Holder<O(I)> {
        // code here
        }
};

...
int main()
{
    ...
    Holder<int(double)> a;
    ...
}

I know that the declaration of one argument template parameter is necessary (since I'm calling the template class with one function-object parameter); but what I do not understand if in this case I'm really providing a template specification. I thought that a specification of a template requires to have defined (not just declared) it, while in this case I simply declared the one-parameter template and then I defined in as a template with two parameter. What is going on technically?

1 Answers

No, this is a valid template specialization (not "specification", that's a wrong word).

The primary (non-specialized) template being declared but not defined doesn't have any special effects. You won't be able to create an instance of it (just like of a non-template struct that's not defined), but that's all.

Related