I'm messing around with C++ extern templates to speed up compilation. I've noticed that Visual Studio 2012 has made some improvements in its handling of `extern template`, but I'm still finding issues. Here's an example:

**main.cpp:**

```
#include <iostream>
#include "Calc.h"

using namespace std;

int main(int argc, char** argv)
{
    Calc<int> c1;
    cout << c1.add(1, 2) << endl;
}

```

**Calc.h:**

```
#pragma once

template <class A_Type>
class Calc
{
public:
    A_Type add(A_Type x, A_Type y)
    {
        return x + y;
    }
};

extern template class Calc<int>;

```

Normally I'd include **Calc.cpp** with `template class Calc<int>;`, ensuring the template is only instantiated once. For this example, I am only compiling **Main.cpp** and expecting it to fail.

The problem is, Visual Studio 2012 will happily compile and link the code above. It's not respecting the `extern template`. The only solution I've found is to do this in the header:

**Calc.h:**

```
#pragma once

template <class A_Type>
class Calc
{
public:
    A_Type add(A_Type x, A_Type y);
};

template <class A_Type> A_Type Calc<A_Type>::add(A_Type x, A_Type y)
{
    return x + y;
}

extern template class Calc<int>;

```

Visual Studio fails to link if the header is like this (complaining about a missing definition for `Calc<int>::add`, as expected). **However**, *g++ 4.6.3* Fails to link either of these examples.

Who is right? If both the prototypes and definitions of functions in a class are specified in the same header file, is there really a difference? Is there any way to specify the "shorter-form" *Calc.h* and have it fail as expected in Visual Studio 2012 (as well as gcc)?