vla*_*don 6 c++ gcc partial-specialization clang
template <class A>
struct Foo {
template <class Bar>
constexpr auto a_method();
};
template <class A>
template <class Bar>
constexpr auto Foo<A>::a_method() {
return 42;
}
template <>
template <class Bar>
constexpr auto Foo<void>::a_method() {
return 42;
}
Run Code Online (Sandbox Code Playgroud)
GCC可以编译这个。
但铿锵不能。错误输出:
<source>:15:27: error: conflicting types for 'a_method'
constexpr auto Foo<void>::a_method() {
^
<source>:4:18: note: previous declaration is here
constexpr auto a_method();
^
1 error generated.
Compiler returned: 1
Run Code Online (Sandbox Code Playgroud)