Dov
Dov

Reputation: 8542

template bool function without <>, what does it mean?

The FLIF image library has the following definition:

template bool flif_decode(FileIO& io, Images &images,
    callback_t callback, void *user_data, int, Images &partial_images,
    flif_options &, metadata_options &, FLIF_INFO* info);

I have seen template specialization, but that still has angle brackets. What does this one mean?

Upvotes: 2

Views: 70

Answers (1)

AndyG
AndyG

Reputation: 41090

The compiler is often able to deduce template arguments in explicit template instantation, which is what this is.

Refer to [temp.explicit] (exmphasis mine)

If the explicit instantiation is for a function or member function, the unqualified-id in the declaration shall be either a template-id or, where all template arguments can be deduced, a template-name or operator-function-id.

The standard provides this accompanying example:

template void sort(Array<char>&); // argument is deduced here

In your example, the function declaration (which is also a definition) looks like this:

template <typename IO>
bool flif_decode(IO& io, /*etc*/) { /*...*/}

So when we later see the explicit instantiation like this:

template bool flif_decode(FileIO& io, /*etc*/);

The compiler is able to deduce that FileIO is the type you wish to use for typename IO

Upvotes: 3

Related Questions