Explicit instantiation of templated constructor for template class

前端 未结 1 1362
半阙折子戏
半阙折子戏 2020-12-18 23:20

I am uncertain if it is a bug in Clang 3.2 or a violation of C++03, but it appears that explicit instantiation of templated constructors for template classes fails, but expl

相关标签:
1条回答
  • 2020-12-18 23:31

    It looks like you've found a GCC bug. These both name the implicitly-declared copy constructor:

    template Foo<int>::Foo( const Foo<int>& foo );
    template Foo<float>::Foo( const Foo<float>& foo );
    

    Per [temp.explicit]p4,

    If the declaration of the explicit instantiation names an implicitly-declared special member function (Clause 12), the program is ill-formed.

    Therefore Clang is correct to reject this code.

    0 讨论(0)
提交回复
热议问题