キーワードによってイニシャライザから推定される型を持つ変数テンプレートがある場合auto、たとえば次のようになります。
template <typename T>
auto * p = (T*)nullptr;
特定の型の変数をインスタンス化する方法 (共有ライブラリからエクスポートするなど)?
GCC と Clang の方法はauto、特定のタイプに置き換えることです。
template int * p<int>;
しかし、MSVC によって拒否され、次のエラーが表示されます。
error C3410: 'p<int>': the type of the explicit instantiation 'int *' does not match the type of the variable template 'auto *'
デモ: https://gcc.godbolt.org/z/66xModTjK
MSVC は、次のようにインスタンス化する必要があります。
template auto * p<int>;
これは、いくつかの奇妙なメッセージで GCC と Clang によって拒否されます。
error: 'auto' variable template instantiation is not allowed
error: declaration of 'auto* p<int>' has no initializer
デモ: https://gcc.godbolt.org/z/7j3nh7Whx
標準に従ってここにあるコンパイラはどれですか?