Question: My requirement is to get an item from a collection using extern "c" function. The method will be as below

```
template<class _Ty,
class _Alloc = allocator<_Ty> >
extern "C" __declspec(dllexport) _Ty* __cdecl GetItem(std::vector<_Alloc>* itr, int index)
{
    if (itr->size() < index)
        return NULL;

    return &itr->at(index);
}

```

While compiling im getting an error as below

```
error C2988: unrecognizable template declaration/definition

```

The use of this `extern` method is to get object data using `pinvoke` from `c#`

Answer: 
No, that's not possible. The standard prohibits templates and their specialisations from having C linkage. Qutoing C++17 (N4659) [temp] 17/4:

> 
> ... A template, a template explicit
>  specialization (17.7.3), and a class template partial specialization shall not have C linkage. ...
> 
> 
>
Actually no, 
 In mentioned template explicit specialization (17.7.3), and a class template partial specialization shall not have C linkage